Integrate Structured Data
You can use Builder CMS Data to create structured reusable data across your site. You can manage the data schema, add, and remove fields within the UI and teammates can create and remove data items in auto-generated structured forms.
Examples include:
- Header navigation links
- Product Details
- Blog authors
- Structured rich content such as user profiles
This tutorial shows you how to add editable navigation links to your site header.
Prerequisites
To follow along with this tutorial, you should have the following:
- a Builder account
- an app in the framework of your choice with the appropriate SDK installed
Add header navigation link data to your app
Create a page with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Create a page with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Create a page, for example in app/[[...page]]/page.tsx, with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Be sure to add use client to your builder.tsx:
Create a page, for example in app/[...page]/page.tsx, with the following contents, replacing YOUR_PUBLIC_API_KEY with your account's Public API Key:
Create a page with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Create a page with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Paste the following code into a new file within the routes directory called $.tsx, making sure to replace YOUR_API_KEY with your Public API Key.
Want the latest and greatest of Remix with Builder? We recommend using Gen 2.
Paste the following code into a new file within the routes directory called $.tsx, making sure to replace YOUR_API_KEY with your Public API Key.
Paste the following code into a new file within the routes directory called $.tsx, making sure to replace YOUR_API_KEY with your Public API Key.
Want the latest and greatest of Hydrogen with Builder? We recommend using Gen 2.
Paste the following code into a new file within the routes directory called $.tsx, making sure to replace YOUR_API_KEY with your Public API Key.
Add a load() function to your script in +page.server.js to get the data from Builder:
Add links to your script and an each block to iterate through the links in +page.svelte to list the nav links.
For an example app that you can add this code to, see the Builder SvelteKit example on GitHub.
Create a page with the following contents. Replace YOUR_API_KEY with your Public API Key:
Create a page with the following contents. Replace YOUR_API_KEY with your account's Public API Key:
Replace src/routes/index.ts with the following contents, replacing YOUR_API_KEY with your account's Public API Key:
Create a standalone component to display navigation links, using CLI:
In app.routes.ts, import NavBarComponent at the top with the other JavaScript imports and define the path for the component and pass it into routes array.
In nav-bar.component.ts:
- Declare a
linksarray to hold the Builder links. - Inside
@Component(), addNavLinksComponentto the imports array. - In the template, use
NavLinksComponentand bind thelinksdata. - Fetch the links data using
fetchEntries()insidengOnInit()lifecycle hook.
Create another component, NavLinksComponent, and replace the placeholder template with a *ngFor, which iterates through the fetched Builder links.
Add a new component for this demo NavBarComponent, for the Builder Navigation links data to load in your app.
In app.routes.ts, import NavBarComponent at the top with the other JavaScript imports and define the path for the component and pass it into routes array.
In nav-bar.component.ts:
- Declare a
linksarray to hold the Builder links. - Inside
@Component(), addNavLinksComponentto theimportsarray. - Inside the constructor, define a
routeof typeActivatedRoute. - In the template, use
NavLinksComponentand bind thelinksdata. - Fetch the data present at the route from the resolver with the
ngOnInit()lifecycle hook.
In the navBarResolver, fetch the links data from the navigation-links model.
Create another component, NavLinksComponent, and replace the placeholder template with an *ngFor, which iterates through the fetched Builder links.
Edit your gatsby-config.js file to configure the Builder SDK, replacing YOUR_API_KEY with your account's Public API Key:
Create a page with the following content:
Fetch your links data from Builder's Content API. Then use that data to create a nav bar within your app's page template.
The example below uses Express.js. Replace YOUR_API_KEY with your account's Public API Key:
Add a new component for this demo: NavLinkComponent, for the Builder Nav link data to load in your app.
Replace the placeholder content in nav-link.component.html with an *ngFor, which iterates through the Builder links the component fetches in the next step:
In nav-link.component.ts, declare a links array to hold the Builder links, inject BuilderServiceand, fetch the data:
Creating a Data model
In the Builder UI, create a Data model so you can create navigation links.
- In the Models section of Builder, Click +Create Model.
- Select Data.
- Enter Nav link as the name for your new Data model.
- Click +New Field.
- Name the first field
labeland give it a type ofText. - Repeat steps 3 and 4 to make a second label named
Urlwith typeurl. - Click Save.
Creating nav link content entries
Use the new Data model to create Nav Link content entries.
- Go to the Content section of Builder.
- Click +New.
- Select Nav Link.
- Give it a label, url, and name.
- Click Publish.
To make more links so that you can iterate through the links in your nav list, click the three dots and select Duplicate. Repeat steps 2-4 for each link you create.
The video below shows how to make three Nav Link entries.
Go back to your website and refresh the page to see your nav links. After your links are rendering, try adding new content entries in Builder. For each new entry, the new link populates the nav.
Live previewing structured data
When working with structured data, it's important to set up live previewing to see real-time updates in the Visual Editor without publishing. This is especially useful for dynamic content like navigation links.
For detailed information and examples, read Live Previewing Data Models and Custom Fields.