You can use Builder Sections to create reusable content across multiple pages. You can manage the code within your codebase, and teammates in the UI can iterate in the Visual Editor.
Examples include:
This tutorial shows you how to create and add an announcement bar section to a page.
For more conceptual information Section Models, refer to the Section Models documentation.
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 Builder SDK installed
Create a Section model so you can make an announcement bar content entry.
- Go to Models.
- Click +Create Model.
- Select Section.
- Enter Announcement bar as the name for your new Section model.
- For all frameworks except Swift: change the Preview URL on the Model Options page to the URL of the page that you added code to display your section. This example uses
http://localhost:####/announcements
, but yours might be different. - Click Save.
The video below demonstrates this process:
When you create or edit an announcement bar section, the Visual Editor displays your content embedded within your Preview URL page, providing visual context and importing styles from your site. It's a live view of your section, as it will look on one of your pages when you publish.
Published Sections typically appear across multiple pages with different URLs depending on how they're targeted. When previewing in the editor, however, they only appear within the Preview URL's page. For more information, refer to Editing and Previewing Your Site.
For more information what Section Models are and how to use them, refer to the Section Models documentation.
Now that your Section model is set up, you can create an announcement bar content entry to add an announcement bar to your site.
- Go to Content.
- Click the + New Entry button and select Announcement bar.
- Build and style your announcement bar.
- Name the content entry.
- Click Publish.
The video below demonstrates this process:
To make your announcement bar display based on targeting, in the section content entry; for example, in the announcement bar:
- Click on the Targeting icon.
- For Where, select URL path.
- Add the URL path you'd like to target.
- Click the Publish button.
The video below shows this process in an integrated Remix app where the targeted URL path is /builder
so that the announcement bar doesn't show up on any other URLs. This process is the same, regardless of the framework you use. The URL path you target, however, might differ.
If you're using Gatsby, you might need to restart your app to render the announcement bar.
When working with sections that use custom fields or data models, it's helpful to set up live previewing. In this way you get real-time updates in the Visual Editor without having to publish your changes.
For detailed instructions on setting up live previewing for your custom fields and data models, visit Live Previewing Data Models and Custom Fields.