A Hypertekt site is a folder of plain files, kept in a git repository. When the site is published, every page is built ahead of time into a snapshot, and that snapshot is served to visitors from a server near them. Pages aren’t made at the moment someone visits, so there’s nothing to slow a page down or to break.
The examples on this page are from Slow Blink, a made-up cat cafe with a menu, events and a page for each cat.
What goes where
site.yaml what the site is: its name, address, language, time zone, and the business
redirects.yaml old addresses and short links
pages/ every file is a page, and its path is its address
layouts/ what pages are rendered inside
partials/ components, used with {{> name}}
collections/ one schema per collection: the fields its items have
content/ one file per item
forms/ one file per form visitors can send
functions/ server functions, which fill collections from other services
assets/ stylesheets, pictures, fonts and scripts, served as they are
snippets/ HTML pasted from elsewhere, like an analytics script
public/ files served at exactly their paths, like favicon.ico
skeletons/ what new files start as in the dashboard
Only site.yaml and one page are needed. A file or folder whose name starts with _ is left out of the build, so it
can hold notes or work in progress.
Pages and their addresses
A file in pages/ is a page, and its address is the file’s path, without .html and without a slash at the end:
| File | Address |
|---|---|
pages/index.html |
/ |
pages/menu.html |
/menu |
pages/events/index.html |
/events |
pages/cats/[slug].html |
/cats/biscuit, one per cat |
pages/feed.xml |
/feed.xml |
pages/404.html |
shown for addresses that don’t exist |
An address with a slash at the end redirects to the address without the slash, so both work for visitors and only one counts for search engines. When a page moves, its old address redirects to its new address. A deleted page’s address tells search engines the page is gone, so they drop the page quickly.
Layouts, partials and slots
A page is HTML with a small template language on top. A page’s front matter is the YAML at the top of its file. The front matter gives the page’s title, its description and any other values the page needs:
---
title: Our cats
description: The cats at Slow Blink who are looking for homes.
---
<h1>{{ page.title }}</h1>
{{#each cats as cat}}
{{> cat-card cat=cat}}
{{/each}}
- A layout is what a page is rendered inside: the
<html>, the header and the footer. The page fills the layout’s{{ slot }}. The layout named insite.yamlis used unless a page names a different layout. A layout can also be rendered inside another layout. - A partial is a component, like a card, with the props it takes and their types written in its front matter. A partial only sees its props, so it’s easy to reuse.
- A
_defaults.yamlin a folder ofpages/gives every page in that folder the same front matter, like a different layout for one part of the site.
partials/cat-card.html is the partial that the page above uses. Its front matter says it takes one prop, a cat:
---
props:
cat: item<cats>
---
<li>
<a href="{{ props.cat | url }}">{{ props.cat.name }}</a>
<p>{{ props.cat.intro }}</p>
</li>
A layout can have more slots than the one a page fills. {{ slot "head" }} in a layout is a named slot. A page fills
the named slot with {{#fill "head"}}…{{/fill}}. Use a named slot for something only one page needs, like a stylesheet.
The <title>, the description, the tags for shared links, structured data for search engines, the canonical address and
the icons are all written into every page’s <head> for you, from the page’s front matter and site.yaml.
Checked before it’s built
Templates are typed. Every collection has a schema, every partial says what props it takes, and every layout says what front matter it reads. The checker catches a misspelled field or a missing prop, and reports the file and line:
- An error stops the build. A draft with an error can’t be published, so the error never reaches visitors as a blank spot or a broken page.
- A warning doesn’t stop the build, but is worth fixing: a picture with no alt text, a title that’s too long for search results, a link to a page that doesn’t exist.
tekt check, tekt start and the dashboard’s Code and Checks tabs all show the same problems.
The only clock is the build
A page shows what was true when the site was built. There’s no “now” in a template, only build.time, so the same
files always build the same site.
To change something on a date, give the item or page showFrom or showUntil, like a seasonal drink that comes off
the menu. Hypertekt builds the site again on that day. To show something different on each visit, like a new photo on
the home page, use sample. It picks from a list each time a page is served.
No code in templates
Templates have values, pipes like {{ cat.story | markdown }}, and a few blocks: if, each and the like. There are
no functions and no expressions to write. Anything that needs real logic goes in a
server function, like fetching reviews from another service. A server function fills a
collection, and templates read that collection like any other.