How to add meta tags / Custom head html to my hosted page entries?

If you’re using builder for hosting ( custom domain or a builder domain (*.builder.live) , you can control what get sent in the head in the html response on that domain, to do so:

On the page entry you’d like to change its head html (for favicon of robots meta tags for example), head to the data tab and scroll to Edit content js + css

Screen Shot 2021-09-28 at 11.32.43 AM

And in the JS section, type in

// example for adding favicon and noindex meta tag
state.customHeadHtml = `
  <link rel="icon" type="image/png" href="..." />
  <meta name="robots" content="noindex,nofollow" />
`

Alternatively if you only care about changing meta tags, you can have a metaTags object on the state and assign each tag to whatever you content you need


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'
state.metaTags.robots='noindex,nofollow'

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

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

I tried this one but the meta tags didn’t show in the header. Can someone help?

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’
state.metaTags.robots=‘noindex,nofollow’

Hi @manuel !

May we see your implementation of this code and where you’ve placed it?

Thanks,
Logan from Builder Account Support

@logan Sorry for the late reply. I tried putting them on the if condition isBrowser