Templates And Snippets
Found a layout that works? Save it once and reuse it everywhere. Templates and snippets let teams reuse proven content structures instead of rebuilding them in every page, block, or catalog attribute.
Use templates for complete starting layouts, and snippets for the smaller, reusable sections you drop into existing content.
Templates: Reusable Starting Layouts
A Hyvä CMS template stores a complete content structure with its metadata and preview thumbnail. Templates can be loaded from the Templates panel in the editor and can be used as default starting content for new content types.
Templates are useful for:
- Standard landing page layouts
- Campaign page starting points
- Product or category content patterns
- Block layouts that should be reused across stores
When saving a template, you can set:
- Template name
- Optional "Created For" tag such as Any, Page, Product, Category, Block, or Menu
- Preview thumbnail, captured from the editor or uploaded manually
In the Templates panel, editors can preview templates, load them into the current content, copy their components to the editor clipboard, star frequently used templates, edit them, or delete them.
Default Templates Per Content Type
Administrators can assign default templates per content type so new content starts with a preferred structure.
Admin path:
Stores > Configuration > Hyvä CMS > Templates > Default Templates
This is useful when every new landing page, category description, or CMS block should begin with an approved layout.
Snippets: Reusable Content Sections
A Hyvä CMS snippet stores selected components from the current editor content. Snippets are intended for reusable sections, not whole pages.
Examples:
- A promotional strip
- A testimonial section
- A trust badge group
- A repeatable CTA block
To create a snippet, select one or more components in the editor and choose Save as Snippet. You can set:
- Snippet name
- Private or shared visibility
- Preview icon, uploaded thumbnail, or captured thumbnail
Private snippets are only visible to the admin user who created them. Shared snippets are visible to other admin users and show the owner in the gallery.
In the snippets panel, editors can preview snippets, load them into the current content, copy them to the editor clipboard, star them, edit them, or delete them where permitted.
Preview Thumbnails For Templates And Snippets
Templates and snippets can use captured previews or uploaded images. Snippets can also use an icon preview. Captured previews are generated from the current editor preview, so they are best created after the content has been saved and visually checked.
Templates And Snippets Configuration
Configure templates and snippets from the Magento admin at:
Stores > Configuration > Hyvä CMS > Templates
Configuration options include:
- Created For options
- Templates and snippets slideout page size
- Snippet icon names
- Default templates per content type
For Developers: How Templates And Snippets Are Stored And Transferred
The templates and snippets feature is provided by the Hyva_CmsTemplate module, which registers template and snippet as Hyvä CMS content providers.
Storage includes template and snippet tables for content, version history, preview data, and Tailwind CSS. Templates and snippets are also available over REST; see Hyvä CMS APIs for how to reach the full, environment-accurate reference in Swagger.
Templates and snippets store normal Hyvä CMS JSON content. When a template or snippet is loaded, its component list is pasted into the active editor content. Any referenced instance components should be transferred with the content when moving between environments.
The module also registers template and snippet handlers with the Transfer Center, so both can be moved between environments through Import & Export. These handlers double as the reference implementation for extending import/export from a third-party module.
Related Topics
- Import & Export - Move templates, snippets, and referenced instance components between environments.
- Instance Components - Understand the reusable database components that templates and snippets may reference.
- Hyvä CMS APIs - Reach the full, environment-accurate REST reference for templates and snippets in Swagger.