SEO Optimizing Builder.io Content
Builder.io is a great tool for SEO optimizing your site. To ensure you take best possible advantage of SEO with Builder.io content, follow the tips below!
Setting page metdata
The most important thing you should do is ensure you set page metadata like the page title. To do this, you can create custom fields for any attributes worth passing through to your pages
Creating custom fields
Most page models by default have a title
field. To create your own, or make a new field for SEO metadata, head over to the /models page, select the relevent model (e.g. your page
model) and create a new custom field for it. For this example we'll create a text
field called title
Setting custom field values in content
When creating content instances for models with custom fields, you can add values for each field from the options tab. Fields marked as required must be filled in in order to publish the content
Rendering the custom fields into your pages
Now, most importantly, you can render these fields into your pages however you need. Take a look at the examples below for implementations of our new title
field
HTML API
Next.js
Gatsby
// Node.js example
// Run when your code doesn't match a page to check Builder for one
let page = await request(
'https://cdn.builder.io/api/v1/html/page?url=' + encodeURIComponent(request.url) + '&apiKey=' + apiKey
)
if (page) {
// Use any templating language, just put the html between your header and footer
res.send(`
<head>
<title>${res.data.title}</title>
</head>
<body>
/* Your header */
${res.data.html}
/* Your footer */
</body>
`);
} else {
// Send 404 page
}
Extend, extend!
The most important part of using custom fields are you can use them for so many use cases! Try making file
fields for meta
tags like og:image
, or boolean
fields for flagging which pages should be crawled vs no-crawl'd using the meta robots
tag.
Up next
Custom models