Building
Snippets
Code attached to the site by a rule instead of to one page.
A snippet is code attached to the site by a rule instead of to one page: an analytics script on every page, a bit of CSS on /pricing, a block of markup at the end of every projects/* page.
Unlike templates, snippets accumulate: every snippet whose scope matches contributes.
What a snippet holds
| Field | What it means |
|---|---|
| Language | js, css, html or php |
| Placement | in <head>, or at the end of <body> |
| Scope | all pages, specific routes, or entries of specific content types |
| Enabled | off keeps it but emits it nowhere |
| Loading | JavaScript only: defer, async, module |
What it ships as
A real file, never inlined soup:
public/scripts/snippets/<id>.js loaded with <script src>
src/styles/generated/snippets/<id>.css imported by every matching page
public/snippets/<id>.php only runs on a PHP hostHTML snippets are injected as markup at the placement you chose.
When to use one
- A third-party script — analytics, a chat widget, a font loader.
- A stylesheet for one section of the site.
- Markup that has to sit outside the page tree, like a skip target or a schema block.
For something one page does, use that page's own script. For something you want to be able to select and style, build it as elements instead — a snippet is code, not part of the tree.
Snippets are the right place for third-party JavaScript, and the wrong place for your site's own behaviour. Menus, animations and overlays already have runtimes that sitereal emits only for the pages that need them.