Skip to content

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.

Available since Hyvä CMS 1.2.0

Templates and snippets were introduced in Hyvä CMS 1.2.0.

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. Loading a template inserts its components into whatever you are currently editing, so it works as a starting point you can then adjust.

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ä Commerce > 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ä Commerce > 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

The templates and snippets feature is provided by the Hyva_CmsTemplate module, which registers template and snippet as Hyvä CMS content providers and as Import/Export handlers, so both can be moved between environments through Import & Export. Templates and snippets are also available over REST; see Hyvä CMS APIs.