Documentation
On this page
Install Cirth for Hugo
Files in Hugo's assets/ directory become public only when a pipeline reads
them. The base template wraps every generated page, so its Cirth link makes
the stylesheet global. Hugo Pipes fingerprints that file and provides its
Subresource Integrity hash.
Three steps: add the file, link it and check it.
1 Add the file #
mkdir -p assets/css
curl -o assets/css/cirth.min.css \
https://cdn.jsdelivr.net/npm/@cirthcss/cirth@0.17.0/dist/cirth.min.css
2 Link it #
In layouts/baseof.html (or layouts/_default/baseof.html before Hugo
0.146):
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ with resources.Get "css/cirth.min.css" | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }}
<title>{{ .Title }}</title>
</head>
The file is already minified; Hugo's minify can be added to the pipe and
keeps Cirth's colours, but saves almost nothing.
3 Check it #
Put this forced-dark region in a page or component that uses the global stylesheet:
<section data-theme="dark">
<article>
<p>Dark, whatever the system scheme is.</p>
</article>
</section>
Run the app, then open
the page while the system uses a light theme. A dark article proves that
Cirth loaded and that data-theme="dark" is working. It remains dark when
the system switches to a dark theme.
Markdown becomes the elements Cirth styles, with no shortcodes or classes.
Customization covers the --cirth-* properties; set
yours in a second stylesheet linked after Cirth. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.