HANIVVRA SUPPORT

Site building guide

How a website is put together in the CMS, and the conventions that keep a site clean, editable and consistent. Read this before creating objects through the API. The AI prompt playbook turns these rules into ready-to-paste instructions for an AI agent.

The content model

The CMS publishes XHTML5 pages assembled from components. Every published page has this anatomy:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Title</title>
    <link rel="icon" type="image/vnd.microsoft.icon" href="/favicon.ico" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="Description" />
    <meta name="keywords" content="Keywords" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
  <body>
    <header></header>
    <main></main>
    <footer></footer>
  </body>
</html>

You never write that document yourself. You create its parts:

Object Supplies Notes
Header The children of <header> Reusable across pages. Usually one per site.
Footer The children of <footer> Reusable across pages. Usually one per site.
CSS A stylesheet Linked from pages by id. A page can link several.
JS A script Linked from pages by id. Several load in alphabetical order of name.
Page The children of <main>, plus properties Properties: title, description, keywords, header, footer, CSS, JS, table of contents, footnotes.
Error page The children of <main> for 401, 403, 404, 500 Fixed set; same properties as a page except name and description.
Form A form rendered from a schema Placed in content as <cms-form id="…"></cms-form>.
Redirect A path that forwards to a page Use when a page is dropped. Renaming a page adds one automatically.

Header, footer and page content must not include the <header>, <footer> or <main> tags themselves, only their children. The CMS adds the wrapping element.

Order of creation

Create headers, footers, CSS and JS before pages, so each page is created with its final properties and never needs a second page_save.

Page name Public URL
index /
about /about.html
animal/index /animal/
animal/cow /animal/cow.html
  • Internal links are root-relative, begin with /, and end with .html, or with / for an index page: /about.html, /animal/, /animal/cow.html.
  • External links get target="_blank" and a rel:
  • rel="noopener" for the site owner's own presence elsewhere (their social profiles, their listings on partner marketplaces).
  • rel="noopener noreferrer" for genuine third-party content.
  • Page names are lowercase: ^[a-z0-9-_~]+(/[a-z0-9-_~]+)*$. Reserved prefixes such as admin/, cms/, css/, js/ and forum/ are rejected.
  • When a page is renamed, the CMS adds a redirect from the old path automatically. When a page is dropped, add a redirect from its old path to the page that replaces it.

Organizing CSS

  • One header and footer used together across the site → one shared stylesheet named nav that styles the header, the footer and the base typography, linked from every page.
  • Several header/footer combinations → a stylesheet per header and per footer, each page linking the ones it uses.
  • Several pages sharing the same <main> styling → a shared stylesheet such as pages; with many distinct page groups, one clearly named stylesheet per group.
  • The home page usually has its own stylesheet, home or front. With many page-specific stylesheets, use a consistent naming scheme.

HTML conventions

  • Write semantic HTML5: header, nav, section, article, aside, figure, details, dl, time, and so on. Upgrade old markup rather than reproducing table layouts, spacer images or presentational tags.
  • Give every page one <h1>, and keep heading levels in order: an <h3> always sits under an <h2>, an <h4> under an <h3>, with no skipped levels. Pick a level for its place in the outline, never for its size; size headings in CSS. The CMS's table of contents is built from this outline.
  • Use lists, tables (for tabular data only), definition lists and figures wherever they make content easier to understand.
  • Prefer one class on a section, and style its children through the hierarchy (section.pricing > ul > li) rather than a class on every element. That way a block of HTML can be promoted to a new class by changing one attribute.
  • Content may later be edited in CKEditor 5, which normalizes markup: it may wrap loose inline content in <p> and may drop empty elements. Be careful with sibling selectors and fragile hierarchies, never leave form controls floating loose, and put &nbsp; inside any element that must stay empty for CSS or JS to use.
  • Pictures and forms that people add. In CKEditor 5, people add a picture as <figure class="image"> containing an <img> (with src, alt, width and height) and an optional <figcaption>. Placement adds a class to the figure: image-style-align-left or image-style-align-right (text wraps around it), image-style-block-align-left, image-style-block-align-right or image-style-align-center (on its own line), or image-style-side. An inline picture is an <img> inside a <p>. Style all of these in the site's main CSS, with max-width: 100% and height: auto on images and floats that stop on narrow screens, so people's pictures look right. Resizing a picture in the editor only adds the class image_resized, with no size, so it has no effect unless the CSS gives that class one. A form placed in the editor becomes <cms-form id="…"></cms-form> with the form's numeric id.
  • Reserved data attributes. API writes keep every data-* attribute, but when a person edits the page in the admin UI, the editor strips data-end, data-index-in-node, data-list-item-id, data-number, data-path-to-node, data-pm-slice, data-start and data-tight. Avoid those names for your own data.
  • No inline CSS or JS. <style>, <script>, style="" and on…="" are stripped or blocked by the Content Security Policy. Use CSS and JS objects. (JSON-LD structured data is the exception; see below.)
  • SVG. Inline SVG is fine for a graphic used on one page. The CMS stores SVG element and attribute names in lowercase (viewbox), which browsers correct automatically. An icon or graphic reused across pages belongs in CSS, as a background-image or mask-image URL; it does not need base64 encoding, and most characters need no escaping (write # as %23).
  • Other embeds are blocked. The Content Security Policy only allows frames from the four video providers below, so map, social media, booking and chat widgets will not load. Link to them instead.
  • Videos from DailyMotion, Rumble, Vimeo and YouTube: use <oembed url="https://…" />. The same element with a root-relative path plays the site's own media: <oembed url="/video/intro.mp4" />.

CSS conventions

  • Size with rem, and set a base font-size on html, body in a stylesheet every page links (usually nav). Adjust that base inside media queries to scale the whole design.
  • Do effects and animations in CSS rather than JavaScript wherever possible.
  • No -webkit- (or other vendor) prefixes for old browsers.
  • Format rules with the opening brace on its own line, and short rules on one line:
@media screen and (min-width: 0px) and (max-width: 62.4375rem)
{
  html, body { font-size: 17px; }
  body:has(#pad-menu-toggle:checked) { overflow: hidden; }

  body > header > nav > ul > li:last-child { border-bottom: none; }

  /* Staggered fade-in for each open-menu item */
  body > header > nav:has(#pad-menu-toggle:checked) > ul > li
  {
    animation: nav-item-in 0.35s ease both;
    overflow-y: auto;
  }
}

Responsive layout

Designs must work on small phones, small and large tablets, typical desktops and very large screens.

  • When the header menu no longer fits, hide it behind a three-line menu button. A CSS-only toggle (a checkbox such as #pad-menu-toggle inside the nav, read with :has()) needs no JavaScript.
  • If the header has a logo, it links to /. Do not put "Home" in the desktop menu, but do include "Home" in the small-screen menu.

Fonts

Use a standard font stack, or any font listed in /js/fonts.json on the site, such as Inter, Roboto, Lato, Merriweather, Playfair Display, IBM Plex Mono or Source Code Pro. Just name the family in font-family; the CMS loads built-in fonts itself, so add no @font-face or import.

JavaScript conventions

Keep JavaScript minimal; prefer CSS. Code written for the CMS follows a house style:

  • Never use continue. Restructure the loop body with if/else.
  • No early returns or guard clauses. Handle the most common case first in the if, and let exceptional cases (typically a throw) fall into the else blocks below it. A run of else { throw … } blocks at the bottom of a function is the intended shape. Deep nesting is fine.
  • Every conditional or loop body has braces, even a single line.
  • The opening brace goes on the line after if/else/for/function; a single short statement may sit inline with its closing brace. else starts on a new line.
  • Two-space indentation.
function parsePort(text)
{
  const port = Number(text);
  if (Number.isInteger(port))
  {
    if (port > 0 && port < 65536)
    {
      return port;
    }
    else
    {
      throw new RangeError('Port out of range: ' + text);
    }
  }
  else
  {
    throw new TypeError('Not a port number: ' + text);
  }
}

Assets

People upload assets through the admin's File Management (see Files and images); the API does not. When preparing a site, place files in matching local folders for upload. All file names are case-sensitive, and subdirectories are allowed.

Local folder Public path Contents
images/ /images/… Every image the site uses.
images/favicon.ico /images/favicon.ico The favicon. It must be a real .ico file with exactly this name; it is also served at /favicon.ico. People can make one in the admin; see Giving your site an icon.
docs/ /docs/… Downloadable documents such as PDFs.
downloads/ /downloads/… Archives and installers, such as ZIP files.
audio/ /audio/… Audio, embedded with <oembed url="/audio/…" />.
video/ /video/… Video, embedded with <oembed url="/video/…" />.

Each folder accepts only its own file types: images (JPEG, PNG, WebP, AVIF, GIF, SVG, ICO, BMP, TIFF) up to 16 MB; documents (PDF, Word, Excel, PowerPoint, text, Markdown, CSV) up to 16 MB; downloads (ZIP and other archives, installers) up to 64 MB; audio up to 32 MB; and video up to 256 MB.

Uploaded files go live at once, without publishing, while pages wait until a person publishes them. Prepare images for the web before they are uploaded: cropped to the shape the layout uses, no larger than they are displayed, WebP for photos, and width and height on every <img>. When a file is replaced by one with a different name, the old file should stay until the pages using the new name are published; see Speeding up pages by using smaller images. A favicon can be made in the admin's image tools from a square PNG or an SVG logo.

Metadata and structured data

  • Give every page its own accurate title, description and comma-separated keywords, never duplicated across pages. Aim for about 50–60 characters in a title and 140–160 in a description, but never cut meaning to fit.
  • The CMS generates <head> itself, so other meta tags, canonical links and social preview tags cannot be added.
  • Where structured data helps (an organization's name, address, phone and opening hours; articles; products; breadcrumbs), describe it with schema.org, either as JSON-LD in a <script type="application/ld+json"> block in the page content, or as microdata (itemscope, itemtype, itemprop) on the visible content. Both are kept by the CMS and by the admin editor. JSON-LD is easier to write and maintain; it must describe what the page actually shows. Inside JSON-LD strings, write </ as <\/.

Accessibility

Target WCAG 2.2 Level AA:

  • Everything is usable by keyboard, in a logical order, with a visible focus indicator.
  • Text and controls have sufficient contrast in every color scheme the site supports.
  • Links have descriptive text; meaningful images have alt text, and decorative ones have alt="".
  • Use <a> for navigation and <button> for actions. Menus and dialogs work with a keyboard and a screen reader.
  • Pages work at 200% zoom and 320 CSS pixels wide.
  • Animation is subtle and turned off under prefers-reduced-motion: reduce.

Built-in features

Site search

If the site has enough content to search, add an element with the id cms-search-button, usually in the shared header, and give it display: none by default. The CMS injects a script that reveals it when search is available. Results open in a dialog with the id cms-search-dialog containing an iframe with the id cms-search-frame; style both.

<div id="cms-search-button">&nbsp;</div>

Table of contents

With the page's generate_toc option on, the CMS builds a table of contents from the page's <h2>–<h6> headings and inserts it after the first <h1> (or at the top of the page if there is none). Each heading gets an id of the form cms-heading-<text>. Turn it on for long, structured pages, not for sectioned landing pages, and style it:

<div id="cms-table-of-contents">
  <details>
    <summary>Table of Contents</summary>
    <ul>
      <li><a href="#cms-heading-introduction">Introduction</a></li>
      <li>
        <a href="#cms-heading-whyavoid">Why Avoid</a>
        <ul>
          <li><a href="#cms-heading-harmfulpractices">Harmful Practices</a></li>
        </ul>
      </li>
    </ul>
  </details>
</div>

Heading ids and links to sections. The table of contents links to each heading by its id:

  • A heading that already has an id keeps it, and the table of contents links to that id. Give an id to every heading that anything links to, from another page, a menu or the same page: short, lowercase and stable, such as <h2 id="publish">. Such links survive rewording and renumbering.
  • Other headings get a generated id: cms-heading- followed by the heading's text in lowercase, with everything except letters, digits, underscores and hyphens removed. 7.5 End-to-end: publishing a page becomes cms-heading-75end-to-endpublishingapage. Accented letters are dropped, not converted: Café & crème becomes cms-heading-cafcrme.
  • If the id is already taken by any element on the page, such as an earlier heading with the same text, a suffix is added: the heading's position among all the page's headings, counting from 0. A repeated heading that is the fourth heading on the page becomes cms-heading-samename-3. The suffix depends on where the heading is, so it changes when headings are added above it. Do not link to such a heading by its generated id; give it an id.
  • Generated ids change whenever the heading's text changes, and exist only while generate_toc is on. Without it, headings get no ids at all. The <h1> is not in the table of contents and gets no id.
  • The admin's editor keeps ids on headings, so people's edits do not remove them.

Footnotes

With generate_footnotes on, every <span> or <a> with the class cms-footnote is moved to a numbered list at the bottom of the page and replaced by a numbered link. Each footnote gets a backlink with the class cms-footnote-backlink. Style both.

<p>The building opened in 1931.<span class="cms-footnote">City records, volume 12.</span></p>

Forms and email addresses

Error pages

The 401, 403, 404 and 500 pages come with plain placeholder content. Give them the site's header, footer and styles, and make the 404 page helpful: a friendly message, a link home, and links to the main sections.

Workflow

  1. Build and check the site locally first: assemble each page from its header, main and footer, and look at it at several screen widths.
  2. Upload in dependency order: headers, footers, CSS, JS, then pages, error pages and redirects.
  3. Everything lands in staging. A person reviews and publishes it in the admin; until then the public site shows nothing new.
  4. Run the links_broken API action and fix every internal link it reports.