Documentation
On this page
Install Cirth for Eleventy
Eleventy does not bundle CSS, so Cirth is copied to the output as a file and linked like any stylesheet. Nothing transforms it on the way.
Five steps: install, copy it through, link it, write content and check it.
1 Install #
npm install @cirthcss/cirth
pnpm add @cirthcss/cirth
yarn add @cirthcss/cirth
bun add @cirthcss/cirth
2 Copy it through #
In eleventy.config.js, written as an ES module, which Eleventy's own
Get Started sets up with npm pkg set type="module":
export default function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({
"node_modules/@cirthcss/cirth/dist/cirth.min.css": "css/cirth.min.css",
});
}
In a CommonJS project, the same function is module.exports = function (eleventyConfig) { … }.
If you would rather not install anything, link the CDN link instead and skip this step.
3 Link it #
In your base layout, for example _includes/base.njk:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title }}</title>
<link rel="stylesheet" href="/css/cirth.min.css">
</head>
<body>
<main class="container">
{{ content | safe }}
</main>
</body>
</html>
4 Write content #
Markdown becomes semantic HTML, which is exactly what Cirth styles: headings, lists, tables, code blocks and blockquotes need no classes.
5 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.
Customization covers the --cirth-* properties; set
yours in a stylesheet linked after Cirth. Package and builds lists the classless,
scoped and print entry points. Return to Framework guides
for another stack.