Global content
Global content is content that is shared across portions of a website. Common examples are website headers, footers, and sidebars. As a developer, you'll specify which components should be global by using global partials or by making modules global. HubSpot provides a different editing experience for content editors that makes it easy to edit the global content and preview the changes across pages before publishing. To learn more about how to edit your global content, check out how to use global content across multiple templates on HubSpot Knowledge Base.
Global content is best used to display the same information across multiple pages. For example, your website's header and footer, such as the header at the top of this page.
Below are some additional examples of areas where you can use global content:
- Secondary navigation for different sections of your website
- Copyright footers (or sub footers)
- Blog post sidebars (for showing recent posts, author listings, and more)
Because global content is used in multiple places throughout a website, it is even more crucial to design and build your global partials and modules for accessibility.
As a developer, you can create global partials and global modules, with a few key differences between them:
- Global partials are a type of template built using HTML & HubL that can be reused across your entire website. The most common types of partials are website headers, sidebars, and footers.
- Global modules are modules that are made up of single or multiple pieces of content that can be used across multiple pages on your site. Some common types of global modules can be items such as blog subscribe forms, secondary navigation elements, and calls-to-action.
All modules and fields inside of your global partials and global modules are easily editable inside of the global content editor.
A global partial is a type of template, which you can create locally through the HubSpot CLI by using the create command, as shown below.
When prompted to pick a type of template, select global partial
.
This will create your template in the desired directory with the following template annotations included in the HTML file.
To see a sample of a global content partial, please reference our boilerplate on GitHub.
You can enable drag and drop content capabilities inside of your global partials by adding in dnd_area
tags similar to enabling them in page templates. View our Drag and Drop Area documentation for more information.
To add a global partial into one of your existing templates, use the global_partial HubL tag while referencing the path to your partial. Below is an example from the CMS boilerplate using this tag.
When global partials are output, they contain a wrapping <div>
around the global partial. This is used by the page editor to identify that the piece of content is a global partial.
Please note: do not use global_partial
within the <head>
of a template. Doing so would result in invalid HTML.
In most situations where you'd want to use a global partial in the header, it may make more sense to use a global module instead with a {%require_head%}
to insert custom code into the head, and still provide module fields.
You can also create global modules in HubSpot by using the design Manager.
Learn more about working with modules in the following related resources:
Thank you for your feedback, it means a lot to us.