Give a site its look

This guide gives a site its look: the built-in style, a style sheet of your own, or a full style folder.

The built-in style

With no key style, a site has the built-in style modern: a menu at the left, the table of contents at the right, a light and a dark theme, and one column on a phone.

The style beetlebug

style beetlebug gives the look of the docs sites of ztcl and ztk. It has no table of contents at the right, and a button in the header for the theme.

Add a style sheet

Make a style folder with one .css file, and name the folder in the site file:

style  look
my-site/
  site.fm
  look/
    site.css

The folder has no page.html, so the page template comes from modern. The build copies look/site.css to assets/site.css and links it from each page. Each .css file at the top of the folder gets a link, in the order of the names. The style sheet of modern is not part of the site, so a style sheet of your own gives all of the look.

Start from styles/modern/site.css of the repository: copy it to the folder, and change the colors of :root and of the dark theme.

The colors and the contrast

The build reads the custom properties of each style sheet, such as --text and --bg, and checks the contrast of each pair that a reader sees: 4.5 to 1 for text, and 3 to 1 for the focus ring. A pair with too little contrast is a warning. Styles and templates lists the pairs.

A page template

Add page.html to the folder to change the markup of each page. A template has slots, such as {{content}} and {{nav}}, and must keep three rules: a skip link first, a <main> with an id, and a <nav> with a name. Copy styles/modern/page.html and change it.

Add head.html for more lines in the <head> of each page, such as a font or a script.

The icon

Put favicon.svg, favicon.png, or favicon.ico in the folder. Each page links to it.

Next: Search.