# How to pull page fields and Open Graph content from a model?

**URL:** <https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148>\
**Category:** CMS\
**Created:** [July 22, 2020, 5:22pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148 "2020-07-22T17:22:55Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![john](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/john/32/20_2.png) [@john](https://forum.builder.io/u/john)\
**Post date:** [July 22, 2020, 5:22pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/1 "2020-07-22T17:22:55Z")

</div>

Hey team, how can I have a Builder page pull its “Page fields” (e.g. SEO page title / description) and its Open Graph Tags dynamically from a custom model in Builder?

We built a model (called Stories) that allows us to publish individual news stories. I’m trying to create an article page that references this model.

Here’s the page in builder: [https://builder.io/content/7358745c5aa6494da0bb79a7395c6aea](https://builder.io/content/7358745c5aa6494da0bb79a7395c6aea)  
Here’s the Story model in builder: [https://builder.io/models/74d0f168c1b641d19941ac54e5d259ca](https://builder.io/models/74d0f168c1b641d19941ac54e5d259ca)  
Here’s an example of a public page producing a Story: [https://thenewpaper.co/story/f67258133c154157b05d47cae83acf77](https://thenewpaper.co/story/f67258133c154157b05d47cae83acf77)

Note: this is related to a separate forum post: [How to pull a custom URL slug / permalink from a model?](https://forum.builder.io/t/how-to-pull-a-custom-url-slug-permalink-from-a-model/146)

---

<div class="post-metadata">

**Author:** ![maddy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/maddy/32/11_2.png) [@maddy](https://forum.builder.io/u/maddy)\
**Post date:** [July 22, 2020, 7:37pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/3 "2020-07-22T19:37:57Z")

</div>

Hi John! Thanks for reaching out.

For pages hosted by Builder, pulling page fields and open graph content dynamically is unfortunately not currently available. Happy to pass this note to our team to get this into our roadmap at some point.

If you are hosting Builder content yourself (e.g. with React), you can do this as described [here.](https://www.builder.io/c/docs/seo)

If you have any other questions, feel free to reach back out 😁

---

<div class="post-metadata">

**Author:** ![john](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/john/32/20_2.png) [@john](https://forum.builder.io/u/john)\
**Post date:** [July 22, 2020, 8:56pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/5 "2020-07-22T20:56:52Z")

</div>

Hi Maddy, thanks for the response!

The pages are indeed hosted by Builder. So, adding this to the roadmap would be great.

We need it so our articles can appear with the appropriate context. For example, the link preview in messaging apps or sharing on social media.

I looked into a few possible workarounds, but unfortunately couldn’t find something that would work.

---

<div class="post-metadata">

**Author:** ![steve](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/steve/32/78_2.png) [@steve](https://forum.builder.io/u/steve)\
**Post date:** [July 29, 2020, 7:49pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/6 "2020-07-29T19:49:54Z")

</div>

Fresh off the press - this is now possible with Builder hosted sites too.

In your [custom JS code](https://www.builder.io/c/docs/guides/custom-code#:~:text=Server%20Rendering) you can create a `metaTags` object and put any meta tag name and values on there, and they will show up on your page rendered by Builder in the

E.g.

```auto

state.metaTags = {}

state.metaTags['og:title'] = 'My dynamic title'
state.metaTags.description = 'My dynamic description'
state.metaTags.title = 'My dynamic page title'
state.metaTags['twitter:card'] = 'Summary'

```

becomes (in the `<head>` of your page):

```auto
<title>My dynamic title</title>
<meta name="description" content="My dynamic description">
<meta name="og:title" content="My dynamic title">
<!-- etc -->

```

---

<div class="post-metadata">

**Author:** ![john](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/john/32/20_2.png) [@john](https://forum.builder.io/u/john)\
**Post date:** [July 29, 2020, 8:32pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/7 "2020-07-29T20:32:34Z")

</div>

This is perfect and exactly what we needed! Gave it a spin and looks like everything is working smoothly.

---

<div class="post-metadata">

**Author:** ![john](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/john/32/20_2.png) [@john](https://forum.builder.io/u/john)\
**Post date:** [October 8, 2020, 6:27pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/8 "2020-10-08T18:27:43Z")

</div>

@steve the meta tag functionality has been working smoothly, but we’re running into an issue where some unrelated tracking / pixel code in the `<head>` stops working properly on pages where we use this feature (i.e. we noticed Google Analytics and our Snap pixel breaks).

More specifically, any page for us that ends with “/news” for us doesn’t appear in Google analytics (in addition to other pixel and tracking-related issues). On the contrary, pages that end in “/candy” for us (which are dynamic URLs, but don’t use the meta tag feature) work just fine.

After digging into it, we noticed that some random parts of the `head` HTML seem to be changing.

Here are a few examples:

**"/news" page where tracking breaks**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/43b7c6d7d64c8505dd99c59f16195877c802d4a0.png)

**normal page where tracking works**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/59870c96f8a71905eed8460288e841ff977ac2d1.png)

**/news page where tracking breaks**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/5a183c8a99887c7799290c915cfa4aeb5b75d0f7.png)

**normal page where tracking works**

 ![image](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/adf5a451e8770834ebad3423df8d86142c82b895.png)

---

<div class="post-metadata">

**Author:** ![kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/kara/32/80_2.png) [@kara](https://forum.builder.io/u/kara)\
**Post date:** [October 12, 2020, 6:03pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/9 "2020-10-12T18:03:51Z")

</div>

Hey John,

Thanks for the detailed response and screenshots! I know we already connected via slack, but wanted to post here as well.

We’ve found a bug with our HTML parsing that can cause this to happen, but you can get around it in the meantime by having one space between opening and closing tag. Let me know if you have any questions!

---

<div class="post-metadata">

**Author:** ![jamesarosen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/jamesarosen/32/360_2.png) [@jamesarosen](https://forum.builder.io/u/jamesarosen)\
**Post date:** [March 9, 2021, 7:25pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/10 "2021-03-09T19:25:41Z")

</div>

Is there a way to specify the favicon? `state.metaTags.favicon` doesn’t seem to do anything. Nor does `state.links = [{ rel: 'icon', url: '…' }]`

---

<div class="post-metadata">

**Author:** ![aziz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/aziz/32/2551_2.png) [@aziz](https://forum.builder.io/u/aziz)\
**Post date:** [March 12, 2021, 12:44am UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/12 "2021-03-12T00:44:14Z")

</div>

Hi @jamesarosen , for adding custom html to the head of a hosted page, use `state.customHeadHtml`, for example your favicon can be added by adding

```auto
state.customHeadHtml = `<link rel="icon" type="image/png" href="..." />`

```

Where href is the link to your favicon image, you can upload images and get an instant cdn link on [builder.io/upload](http://builder.io/upload) , then copy the link and add it to the href attribute in the example above.

---

<div class="post-metadata">

**Author:** ![jamesarosen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/jamesarosen/32/360_2.png) [@jamesarosen](https://forum.builder.io/u/jamesarosen)\
**Post date:** [March 12, 2021, 1:32am UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/13 "2021-03-12T01:32:57Z")

</div>

It looks like there’s a small bug in `state.customHeadHtml` when used in combination with `state.metaTags`: it renders `<html><head>` before the content, but we’re already in the `<head>`. The `<meta>` tags end up in the `<body>`.  
 ![builder-head-html](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/68223e54789eb61092249adbaace1c6d9c3c16f1.png)

---

<div class="post-metadata">

**Author:** ![aziz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/aziz/32/2551_2.png) [@aziz](https://forum.builder.io/u/aziz)\
**Post date:** [March 12, 2021, 5:36pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/14 "2021-03-12T17:36:42Z")

</div>

I see the issue, thanks for reporting @jamesarosen, we’re working on a fix to that API, will let you know once it’s released.

---

<div class="post-metadata">

**Author:** ![aziz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/aziz/32/2551_2.png) [@aziz](https://forum.builder.io/u/aziz)\
**Post date:** [March 15, 2021, 7:01pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/15 "2021-03-15T19:01:15Z")

</div>

Custom head html fix went to production today, sorry you ran into this issue, it should be resolved now. @jamesarosen

---

<div class="post-metadata">

**Author:** ![zhitch](https://avatars.discourse-cdn.com/v4/letter/z/ba8739/32.png) [@zhitch](https://forum.builder.io/u/zhitch)\
**Post date:** [May 17, 2021, 6:23pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/16 "2021-05-17T18:23:16Z")

</div>

> [@aziz](#):
>
> `state.customHeadHtml = `\<link rel=“icon” type=“image/png” href=“…”`

Where would this code go exactly?

---

<div class="post-metadata">

**Author:** ![aziz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/aziz/32/2551_2.png) [@aziz](https://forum.builder.io/u/aziz)\
**Post date:** [May 18, 2021, 7:33pm UTC](https://forum.builder.io/t/how-to-pull-page-fields-and-open-graph-content-from-a-model/148/17 "2021-05-18T19:33:19Z")

</div>

This is in your content js code section in the data tab ( all the way down)

 ![Screen Shot 2021-05-18 at 12.31.08 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/e88cb60463bcad859e40fd3131d4b0a320650d3c.png)  
Press `Edit content js + css`  
Then add your custom code in the `js` section  
 ![Screen Shot 2021-05-18 at 12.31.56 PM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/1X/59ad054455c2cd70665c2cc53956da2a36a3b486.png)
