sitereal
v0.1

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

FieldWhat it means
Languagejs, css, html or php
Placementin <head>, or at the end of <body>
Scopeall pages, specific routes, or entries of specific content types
Enabledoff keeps it but emits it nowhere
LoadingJavaScript 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 host

HTML 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.