reviews (star ratings with the average, as a section or under a product, which then gets AggregateRating), glossary (A to Z with a letter row, each term linkable, DefinedTermSet), logo-wall (a still grid, muted logos become light outlines in dark mode, white tiles on request), videos (a library from your own files: page per video with captions and transcript, list, feed, Latest videos section, VideoObject), directory (entries grouped by category with a page each), link-in-bio (one page of big buttons, no menu), status-page (components from data/status.yaml, incidents with a feed), coming-soon (a holding page with a launch date and a form, no menu) and timeline (dates down a line). Template functions: sortBy, ratings and stars. formatDate takes a date with a time, as front matter's date: does, and now is in the site's timezone. A layout can leave out the site's menu by redefining nav, but only with a non-empty body: Go keeps the old template when the new one is empty.
8.2 KiB
Packs
A pack is how sections, templates and styles are shared between sites. It's a folder or a git repository of plain files. Installing it copies them into the site, where they're the site's own: reviewed, versioned, changed and published like everything else.
A pack carries no code. That's the point. WordPress plugins run with the site's full rights, and that's where most of its security problems came from. A pack's templates run through the same escaping, checks and Content-Security-Policy as the site's own.
Using one
hotdog-cms pack add calendar # one that comes with HotDog CMS
hotdog-cms pack add ../faq-pack # a folder
hotdog-cms pack add https://git.example.org/packs/[email protected] # a repository, at a tag
hotdog-cms pack list
hotdog-cms pack remove faq
addinstalls the files and records the pack insite.yaml. Commit both, ideally through a review.- Running
addagain with a newer version upgrades it. Files the new version no longer has are removed. - A file already in the site that the pack didn't put there is never
overwritten, unless you add
-force. Two packs can't install the same file. removetakes the pack's files out and forgets it.listalso names the packs that come with HotDog CMS:- author-box: who wrote an article, at its end, with a photo, bio
and links, from
data/authors.yaml; - breadcrumbs: a Home › Articles › This page trail above a page's title, and the same trail for search engines;
- calendar: events, an upcoming-events section and a feed people subscribe to (see events.md);
- changelog: release notes, a page per release and all of them on one page, a feed to follow and a "What's new" section;
- coming-soon: a holding page for before launch or during maintenance, with when you'll open and a sign-up form;
- contact-forms: ready-made forms for a quote, a booking and a mailing list, and a section that puts any form beside your email, phone and address;
- directory: a listing of businesses, members or places, grouped by category, with a page each;
- docs: a documentation section with a sidebar, part pages and
previous/next links, in the order
data/docs-nav.yamlgives; - downloads: files to download, with their type and size;
- faq: questions that open to show their answers;
- gallery: a grid of pictures that open full size, with no script;
- glossary: terms and what they mean, A to Z, each with its own link;
- jobs: openings with closing dates; closed ones leave the list by themselves;
- link-in-bio: one page of big buttons, for the link in a social profile;
- location-and-hours: address, map link, phone, email and opening
hours, from
data/location.yaml, as a section or a partial; - logo-wall: a grid of logos, for customers, sponsors or "as seen in";
- menu-and-prices: a price list in groups, and plans side by side;
- payment-links: buy, book and donate buttons that open your payment provider's own checkout (Stripe, PayPal, Square, Ko-fi, Liberapay…);
- podcast: episodes with a player, and the feed podcast apps
subscribe to (
feed_format: podcast); - portfolio: projects with a cover, details and pictures, a list page and a section;
- recipes: ingredients, steps, times and servings;
- related-posts: at the end of an article, the ones sharing the most tags with it;
- reviews: star ratings from customers, with the average, as a section or under a product;
- series: articles in parts, with "Part 2 of 5", every part listed and links to the previous and next part;
- share-links: plain share links for Mastodon, Bluesky, LinkedIn and email, with no tracking;
- shop: a product catalog with a page per product, each Buy button opening your payment provider's checkout (no cart);
- status-page: whether your services are working, open and past incidents, and a feed;
- table-of-contents: a long page's headings, linked, at its top;
- tables: tables from a spreadsheet saved as CSV (or YAML), with a caption and row headings, that scroll on phones;
- team: a page per person, a list of everyone and a section;
- testimonials: quotes with a name and a role;
- timeline: dates down a line, with what happened at each;
- videos: a video library from your own files, with a page per video, a feed and a "Latest videos" section.
- author-box: who wrote an article, at its end, with a photo, bio
and links, from
-sitepicks the site folder (default: the current one).
Search engines. The faq, location-and-hours, team, recipes, jobs and shop
packs are also written as schema.org data (FAQPage, LocalBusiness, Person,
Recipe, JobPosting, Product), and so are the breadcrumbs pack's trail
(BreadcrumbList, on every page once the pack is installed), a glossary
section's terms (DefinedTermSet), a video page (VideoObject) and a product's
reviews (AggregateRating), which search engines use for richer results. A pack can't carry the
<script type="application/ld+json"> that holds it, so HotDog CMS
builds it (pageData in templates) and the starter's partials/schema.html
writes it. Sites started before HotDog CMS 0.2 can add the same two lines to
theirs:
{{ range pageData . }}<script type="application/ld+json">{{ . }}</script>
{{ end }}
# site.yaml, written by hotdog-cms pack
packs:
- name: faq
version: 1.2.0
source: https://git.example.org/packs/[email protected]
commit: 4f2c9e1…
files:
- assets/packs/faq/faq.css
- sections/faq.html
In the editor, a pack's sections appear in the section library like any other, marked with the pack they came from.
Making one
faq-pack/
pack.yaml
sections/faq.html
assets/faq.css
README.md
LICENSE
# pack.yaml
name: faq # lowercase letters, digits and dashes
version: 1.0.0
title: FAQ
description: Questions and answers that open and close.
license: MIT
author: Example Studio
# Settings its layouts expect, added to site.yaml's collections: on install
# unless the site already configures that collection.
collections:
faq:
layout: faq-page
# Shown after installing: what to do next.
notes: |
Add questions as content/faq/<name>.md.
Collection settings are data, not code, and are checked against what
site.yaml accepts. Removing a pack leaves them, since they may have been
changed and do nothing without the pack's layouts.
What a pack can hold:
- Templates:
.htmlfiles directly insections/,partials/orlayouts/, installed at the same place in the site. Sections declare their fields the usual way (see themes.md). - Forms:
.yamlfiles directly informs/(see forms.md). A form is copied in once and is the site's own from then on, since the site sets where it sends: upgrading or removing the pack leaves it alone, and a site's own form of the same name is kept. A pack's form must send to a placeholder address such as[email protected], never one the pack's author chose, and can't turn on Turnstile, which loads another site's script.hotdog-cms checkwarns until the site sets its own address. - Assets: stylesheets, pictures (PNG, JPEG, WebP, GIF, AVIF) and fonts
in
assets/. They're installed underassets/packs/<name>/, so two packs never collide. Refer to them that way:{{ asset "packs/faq/faq.css" }}. README,LICENSEandCHANGELOGfiles stay in the pack.
What a pack can't hold, and hotdog-cms pack check says so:
-
JavaScript;
-
SVG, which can carry scripts (use PNG or WebP);
-
a template with a
<script>, an event handler (onclick=and the like), ajavascript:link, or an<iframe>,<object>or<embed>; -
symbolic links, or anything outside the folders above.
hotdog-cms pack check ./faq-pack # what it would install, or what's wrong
What isn't a pack
A step that has to run something, such as a search index or an image
pipeline, isn't a pack. It's an operator's before or after step on a
publish target (see publishing.md). Those are trusted,
because the operator chose them. They live only in the operator's targets
file, never in site.yaml.