Skip to content
MCG Filament CMS Demo

Snippets

A snippet is a group of blocks written once and shown on many pages, such as an office address, a promotional panel or a standard call to action. Snippets are listed in the sidebar as Snippets.

To show a snippet on a page:

  1. On the page's edit screen, select Add block and choose Snippet.
  2. In the block's Snippet field, choose the snippet.
  3. Save the page.

The snippet's blocks render as though they were part of the page.

Editing a snippet changes every page that shows it. Before editing one, check its Used on column under Snippets, which states how many pages embed it; hovering over the count lists them.

A snippet has no address of its own and cannot be visited directly. Its content is not returned by site search, because it belongs to no single page.

Converting a block to a snippet

A block already built on one page can be turned into a snippet, so it can be reused on other pages without being rebuilt. Every block except a Snippet block has a Convert to snippet action in the row of controls on its header.

  1. On the page's edit screen, find the block and select Convert to snippet. A window headed Convert this block to a snippet opens.
  2. Enter the Name for the snippet. The name is shown in the snippet picker and in the Snippets list; visitors never see it.
  3. Decide whether to tick **Move this block's custom classes into the snippet**. It is off by default, which leaves the block's CSS classes on this page. Classes usually describe how this page positions the block, and moving them into the snippet would apply that positioning on every page that embeds the snippet. Tick it only when the classes describe the block itself.
  4. Select Convert.

The block is replaced in place by a Snippet block embedding the new snippet, so the page reads exactly as before. A container, such as a Section or a set of Columns, is converted whole, with every block inside it.

Two consequences follow:

  1. The snippet is created immediately, but the page is not saved. The page now has unsaved changes. Leaving the page without saving undoes the swap on this page and leaves the new snippet under Snippets, to be deleted there.
  2. A block that fails its own validation cannot be converted. A snippet is saved as soon as it is created, so an invalid block would be refused, with the message That block cannot become a snippet yet. This happens to an older block whose validation rules changed after it was last saved. Fix the block on the page, save the page, then convert the block.