Use HTML Includes in your themes
With HTML Includes, you can define chunks of HTML that you want to be rendered into the HTML for a page. This can give faster load times and improved maintainability, since you can use external front-end assets. You can define any HTML, and configure it to render on any of the available locations in your HTML. HTML Includes are configured for the SXA themes, and you can use them both for themes that are assigned to components and that are assigned to a page.
Before using HTML Includes for a theme, make sure the HTML structure is correct, so using the HTML Includes does not break the structure of existing pages that use the theme.
Create an HTML Include
If you want to use HTML Includes, you must create them for the theme.
To create an HTML Include for an SXA theme:
-
In the Content Editor, navigate to the theme you want to create an HTML Include for, for example, /sitecore/media library/Themes/Basic2.
-
Right-click on the HTML Includes folder, and select HTML Include.
TipIf your theme does not already have this folder, you can create it using this template, which is available as an insert option: /sitecore/templates/Foundation/Experience Accelerator/Theming/HTML Snippets/HTML Snippets Folder.
-
Give the include a Name.
-
Click OK.
Configure an HTML Include
For HTML Includes to properly render on pages using the theme, you must configure them.
To configure an HTML Include:
-
In Content Editor, navigate to the HTML Include you want to configure.
-
In the window for the HTML Include, specify the HTML and Location fields.
Field |
Description |
---|---|
HTML |
The HTML content of your HTML Include, for example |
Location |
Specifies where in the output HTML to render the HTML Include. Can be |