Trailhead: moving from Eleventy
In your terminal ssqch docs --from eleventy
SiteSquatch keeps many of the same ideas as Eleventy (a data cascade, collections, pagination, layouts) but isn't a drop-in replacement: the config is one object instead of method calls, and names are SiteSquatch's own. Nunjucks and Liquid templates render as they are, so the first build usually comes early, and what's left is the config and a few front-matter keys.
The ReverentGeek blog made this move (from Eleventy with Edge templates), and the blog-categories example is inspired by a real-world Eleventy site.
Scouting
ssqch scout (see Scouting a site) lists what this guide describes for your site, with file and line, and drafts the mechanical part: it renames *.11tydata.* data files and the eleventy: image attributes below (Eleventy's front matter keys work as they are), writes a first ssqch.config.js from the Eleventy config (folders, passthrough copies, watch targets, template engines, pathPrefix, and filters and shortcodes that use only their own arguments, copied as written, in the config's own indentation), swaps @11ty/eleventy for ssqch in package.json and its scripts (eleventy is ssqch build, eleventy --serve is ssqch serve), and lists what's left, including a lockfile to update or a stale one from another package manager, each with its file and line: every filter, shortcode, collection, transform and plugin, and what it becomes. It changes nothing on its own: --write-draft writes the new files and --patch move.patch the edits, to read and git apply. Run it again during the move to see what's left.
A whole move with the loop, scout's report before, halfway and at the end, with baseline and diff between: A move, step by step.
What scout also finds: what the site's own modules add: the config is followed through its relative imports (registerSiteFilters(eleventyConfig) in lib/, a plugin of the site's own), and each module's filters, shortcodes, collections and transforms are listed with its own file and line, the self-contained filters copied into the draft as the config's are. Eleventy's packages in data files and other modules (eleventy-img or eleventy-fetch run by a data file) are listed with what replaces them. The packages that came with @11ty/eleventy and that the site's own code imports without listing them (slugify in the config, browser-sync in a gulpfile, gray-matter in a data file): it adds each to package.json beside where Eleventy was, at the version installed, since the output can depend on it, or, with no node_modules to read the version from, lists it to add by hand. The filters and shortcodes the templates use that nothing defines (not the template language, not ssqch, not the Eleventy config), each with how many templates use it and the first place: Eleventy's built-ins (log, getCollectionItem and getCollectionItemIndex, which it ports into the draft's filters, and slug, which it says how to port: Eleventy's keeps punctuation ssqch's slugify drops), the RSS and navigation plugins' (and what replaces them), and any other name, which is usually a plugin's or a helper module's. markdown-it's breaks, linkify and typographer and markdown-it-implicit-figures come along as the draft's markdown options, and so do the defaults where the two Markdowns write different markup, each with a comment: headingIds: false when the site has no markdown-it-anchor (Eleventy's headings had no ids; the ReverentGeek blog had 380), and indentedCode: false for Eleventy 3 (and Eleventy 2 without a library of its own), which turns indented code blocks off. Take a line out to move to ssqch's. It also lists what changes the output before the first diff: a Date printed as it is ({{ date }}: Date.toString() in Eleventy, ISO 8601 in ssqch), date code that reads the machine's time zone (toLocaleDateString without timeZone, luxon's fromJSDate without zone), pagination over collections, templates in a folder that's passed through (Eleventy rendered them, ssqch copies them), a script that runs ssqch build beside another command with &, and a second build tool (a gulpfile, webpack, PostCSS) with what ssqch has for each part it does. With markdown-it-anchor (and no slugify of the site's), the draft has headingIds: "markdown-it-anchor"; with dataTemplateEngine, a data file's {{ '/about/' | url }} becomes "/about/"; ignores.add() joins .eleventyignore in ignore; and a file passed through twice is listed once.
The config
.eleventy.js becomes ssqch.config.js, an ES module whose default export is the config: an object, or a function of { env, serving } that returns one.
import { defineConfig } from "ssqch";
import { rssPlugin } from "ssqch/rss";
export default defineConfig(({ env }) => ({
dirs: { input: "src", output: "_site" },
templateFormats: ["njk", "md"],
markdownEngine: "njk",
filters: { year: (d) => d.getUTCFullYear() },
collections: { posts: (pages) => pages.byGlob("src/posts/*.md") },
plugins: [rssPlugin()],
}));
| Eleventy | SiteSquatch |
|---|---|
addFilter, addNunjucksFilter | filters: { name: fn }, callable from every template language ({{ name(x) }} in Edge, {{ x | name }} in Nunjucks and Liquid). Async functions are awaited. |
addShortcode | A filter too. In Nunjucks, a config filter is also a tag, so {% image "a.png", "Alt" %} keeps working as it is. |
addPairedShortcode | In Nunjucks, the same filter with a closing tag: {% callout "tip" %}...{% endcallout %} calls callout(content, "tip"). In Markdown, a ::: name container (_includes/containers/name.*). In Edge, a component. |
addCollection(name, api => ...) | collections: { name: (pages) => ... }. getAll() is pages.all(), getFilteredByTag(t) is pages.byTag(t), getFilteredByGlob(g) is pages.byGlob(g). |
addGlobalData | data: { name: value or function } |
addTransform | transforms: { name: (content, page) => content } |
addPassthroughCopy | passthrough: a path, a glob, or { from: to } |
addWatchTarget | watch |
watchIgnores | serve: { ignore: [...] }: files only a watcher (Tailwind, PostCSS) reads, so saving one doesn't rebuild |
addPlugin | plugins: objects with any of these keys, or functions that return one |
addLayoutAlias("post", "layouts/post.njk") | layoutAliases: { post: "layouts/post.njk" } |
.eleventyignore, ignores.add(), .gitignore | ignore: ["drafts/**"], globs from the input folder. ssqch reads neither file, so a page one of them kept out of the build is published until it's listed (ssqch scout carries all three into the draft's ignore, .gitignore's for the pages it hides now). |
on("eleventy.before"), on("eleventy.after") | beforeBuild, afterBuild. One that only reads the output (Pagefind, a list of files) says so, { run, reads: "output" }, and ssqch serve then renders only the pages an edit can reach (Search) |
dir | dirs (dir works too) |
markdownTemplateEngine, htmlTemplateEngine | markdownEngine, htmlEngine (Eleventy's names work too) |
setLibrary("md", markdownIt(...).use(...)) | markdown: { ... } options, render hooks and containers (below), or keep your markdown-it as it is: engines: { md } (Your own Markdown library) |
pathPrefix | base: "/repo/" (pathPrefix works too). Links in templates need no url filter (it works, and gives the URL back as it is): ssqch adds the base to every URL from the site's root in the HTML it writes, and withBase() covers scripts and JSON. |
The config is ESM, though your own CommonJS files (require, module.exports) load too. ssqch runs on Node, like Eleventy, so a site's packages run as they are: luxon, date-fns, lodash, markdown-it, slugify-style helpers and the libraries Eleventy brought along all work, and so do servers, child processes and native addons.
Where Eleventy's word means the same thing in ssqch, it works as it is: ssqch dev and ssqch build --serve serve, --pathprefix is --base, and the config options and front matter keys marked "works too" in these tables do what ssqch's names do, so a site can move first and rename later. Each one says ssqch's name once (note: pathPrefix works; ssqch calls it base), and setting both names is an error. Filters too: url, and a slugify that's the same in every template language.
ssqch serve reads the config again when it changes, so there's no restart while you port it.
Front matter and data
| Eleventy | SiteSquatch |
|---|---|
eleventyComputed | computed (eleventyComputed works too) |
eleventyExcludeFromCollections | excludeFromCollections (Eleventy's name works too) |
templateEngineOverride: md | render: md (or a list, or false). templateEngineOverride works too, "njk,md" included. |
permalink, layout, tags, pagination, date | The same |
*.11tydata.js, *.11tydata.json | *.data.js, *.data.json |
_data/*.js and directory data (posts/posts.json) | The same |
page.url, page.fileSlug, page.inputPath, page.outputPath, page.date | The same, plus page.headings and page.excerpt in layouts. Dates in file names (2024-06-01-post.md) work the same way. |
layouts: "_includes/layouts" and layout: post | dirs: { layouts: "_includes/layouts" } |
addDataExtension("yml", ...) with js-yaml | Built in: YAML, TOML and JSON data files load as they are, and readData(path) from ssqch reads one in code |
eleventyNavigation | nav front matter with the same key, parent, order, title and url, turned into a tree with pagesTree(collections.all), and collections.all | eleventyNavigation: "Feature" is pagesTree(collections.all, { root: "Feature" }) (a parent no page has is a heading, and title falls back to key, as in eleventy-navigation); or a data file such as _data/nav.yml. navTree, navPager and navBreadcrumbs mark the current page, and give previous/next and the trail. To keep eleventy-navigation's filter instead, leave the front matter as it is and define the filter with the package's function: import navigation from "@11ty/eleventy-navigation/eleventy-navigation.js", then filters: { eleventyNavigation: (pages, key) => navigation.findNavigationEntries(pages, key) } (ssqch scout leaves the front matter alone when templates call that filter). |
eleventy.env, process.env.ELEVENTY_ENV | The ssqch template global (ssqch.env, ssqch.serving), and SSQCH_ENV |
Plugins
| Eleventy plugin | SiteSquatch |
|---|---|
@11ty/eleventy-img | imagePlugin() from ssqch/image: every <img> becomes a <picture>. Its defaults differ (Images from eleventy-img). |
eleventy-img's Image(src, options) in a data file or a shortcode | await image(src, { widths, formats }) from ssqch/image (Images from eleventy-img) |
eleventy-plugin-nesting-toc's toc filter | toc(content), built in. It writes the list alone, so the element around it is the layout's (A table of contents). |
The RSS plugin's 1.x names, rssDate and rssLastUpdatedDate | With rssPlugin() they work, and say ssqch's names once: dateToRfc3339, and getNewestCollectionItemDate | dateToRfc3339 |
@11ty/eleventy-plugin-rss | rssPlugin() from ssqch/rss for a feed template's filters, or its feedPlugin({ url }) for the feed itself (v2's feedPlugin, with ssqch's names: type is format, outputPath is output, collection: { name, limit } is collection and limit, metadata is url, title, description and author) |
@11ty/eleventy-plugin-syntaxhighlight | markdown: { highlight: true }, or highlight: { classes: "prism", css: false } to keep your Prism theme's CSS (Another highlighter's classes) |
A Prism language added in the plugin's init({ Prism }), or its alias option | markdown: { highlight: { languages } }: a function that returns [text, kind] tokens, another language's name (cho: "chordpro"), or a .sublime-syntax file (ssqch docs languages) |
| markdown-it-anchor | Heading IDs are built in; add anchor links with a heading render hook (Prism and permalink markup) |
| markdown-it-footnote | Built in |
| markdown-it-container | Built in: ::: name |
| markdown-it-attrs | {#id .class} on headings |
| markdown-it-implicit-figures | markdown: { figures: true } |
| An HTML minifier transform | minifyPlugin() from ssqch/minify |
| A link checker | linksPlugin() from ssqch/links |
| A sitemap template | sitemapPlugin({ url }) from ssqch/sitemap |
| Redirect pages made with pagination | redirectsPlugin() from ssqch/redirects, with aliases front matter |
Images from eleventy-img
imagePlugin() takes the place of the eleventy-img transform, and both encode with sharp. With no options, they don't write the same thing (compared with eleventy-img 7.1.1):
| eleventy-img's transform | imagePlugin() | |
|---|---|---|
| Formats and widths | WebP and JPEG, at the original's width | WebP and the source's own format, at 300, 600, 900, 1200 and 1500 pixels, never wider than the original |
| An animated GIF | A still WebP and JPEG | The GIF as it is, still moving |
| An SVG | Drawn as WebP and JPEG | The SVG as it is |
| A link to a local image | Left as written | Pointed at a generated copy (linkedImages: false leaves it) |
Added to the <img> | width and height | Those, with loading="lazy", decoding="async" and sizes="auto" |
For the transform's markup while the move is checked (SVGs are still copied, and that's the difference left):
import { imagePlugin } from "ssqch/image";
export default {
plugins: [imagePlugin({
formats: ["webp", "jpeg"],
widths: ["auto"], // the original's width
defaultAttributes: {},
linkedImages: false,
webpQuality: 80, avifQuality: 50, avifEffort: 4, jpegQuality: 80,
})],
};
Quality settings: eleventy-img hands sharpWebpOptions, sharpAvifOptions and sharpJpegOptions to sharp, and imagePlugin()'s four quality options are the same sharp numbers, so a number moves across as it is:
| eleventy-img | imagePlugin() | Unset in eleventy-img (sharp's default) | Unset in ssqch |
|---|---|---|---|
sharpWebpOptions: { quality } | webpQuality | 80 | 75 |
sharpAvifOptions: { quality } | avifQuality | 50 | 41 |
sharpAvifOptions: { effort } | avifEffort | 4 | 2 |
sharpJpegOptions: { quality } | jpegQuality | 80, without mozjpeg | 89, with mozjpeg |
ssqch's JPEGs are always mozjpeg's, so at the same number they're other bytes, usually fewer. With these settings, one test picture's WebP came out byte for byte the same as eleventy-img's, its AVIF within 0.1% of the size, and its JPEG smaller. sharp's other settings (lossless, sharpPngOptions, sharpOptions) have no option: passing eleventy-img's names is an error that lists ssqch's.
Image() in a data file or a shortcode is image(). The result has eleventy-img's shape, { webp: [{ format, width, height, url, sourceType, srcset, filename, outputPath, size }], jpeg: [...] }, the smallest first:
// src/_data/hero.js
import { image } from "ssqch/image";
export default async function () {
const files = await image("src/img/ridge.jpg", { widths: [600, "auto"], formats: ["webp", "jpeg"] });
return files.jpeg.at(-1); // the widest JPEG
}
- Options:
widths,formatsandname(a name of your own for the files). The original's width is"auto"; eleventy-img'snullis an error. Quality settings go onimagePlugin(), andoutputDirandurlPathtoo: given toimage(), they're errors. formats: ["auto"]puts the files under the format they became and underautoas well, so a loop overObject.values(files)sees them twice.- No
generateHTML(): write an<img>and let the plugin make the<picture>, or build the tags from the result (Another crop on a phone does). Remote URLs aren't taken.
An Image()-made social card is imageUrl(), a template function on every site. It takes the image's address on the site, not its file, and gives one copy, { url, width, height, type, format }:
{% set card = imageUrl("/img/ridge.jpg", { width: 1200, format: "png" }) %}
<meta property="og:image" content="{{ absoluteUrl(card.url, site.url) }}">
<meta property="og:image:width" content="{{ card.width }}">
Templates
Nunjucks (.njk) renders with Nunjucks, the library Eleventy uses (ssqch's fork of it, which prints values as Nunjucks does: true, a,b), Liquid with liquidjs, Eleventy's Liquid library, and EJS (.ejs) with ejs (include() reads from _includes, as in Eleventy). Most templates work unchanged, shortcodes included; Each template language lists what differs (Liquid shortcodes become filters, for one). JavaScript templates (.11ty.js) need rewriting in a template language, or an engine of your own for a new extension: engines: { page: (source, data) => html } renders .page files. WebC isn't supported.
Things that work differently
- Templates in a passthrough folder aren't pages. Eleventy renders a
feed.njkinside a copiedstatic/folder and also copies it. ssqch only copies it. Move templates out, or use a glob for the files to copy ({ "src/static/*.{png,ico,svg}": "." }). - In Nunjucks, a filter called as a function loses to page data of the same name. With
image:in a post's front matter,image(src)is that string, not the filter.src | imageand the tag form ({% image src %}) always reach the filter, and Edge'simage(src)does too. date: git Last Modifiedanddate: Last Modifiedare Eleventy's words, and in ssqch they're adatethat isn't one (the build stops at its line). Leavedateout of those pages: an undated page takes its file's time, or withdateFallback: "git"its last commit's, which isgit Last Modified. A post that keeps its publisheddateand shows when it changed readspage.updatedinstead (A post's "updated" line).git CreatedandCreatedhave no equivalent: write the date.- A page without a date has its file's modification time, not its creation time as in Eleventy. A footer with
{{ page.date.getFullYear() }}can print a different year on every page, andssqch diffsaysdiffer only in dates or years. For a copyright year, use the build's time:{{ now() | dateformat("%Y") }}. In data files,dateformatalso saves formatting dates by hand (toLocaleDateString). While serving, every save of one renders the pages that show its date (every page that reads collections, when the site's code sorts by dates);dateFallback: "git"gives it its last commit's date instead (ssqch scoutcounts the pages that have none). slugifyisn't Eleventy'sslugify, which is the@sindresorhus/slugifypackage. Plain titles come out the same; accents, symbols and curly apostrophes don't. ssqch keepsthomas-sjögren, drops the&ofOld Growth & Cedar(old-growth-cedar, where Eleventy writesold-growth-and-cedar) and joinsDrew’sasdrews(Eleventy splits that one,drew-s).slugify(title, { ascii: true })takes accents off and spells out&, though not as Eleventy does every time (200%becomes200-percent, and Eleventy writes200).apostrophes: "separate"splits at an apostrophe, the straight one too, andseparator: "_"changes the dash.stripTags: truedrops HTML tags before slugging (Use <code>title</code>isuse-title). To keep every URL, keep the filter itself (below, in Moving with identical output first), and runssqch diffbefore swapping one for the other: a changed URL is a broken link.- A table of contents comes without a wrapper.
toc()writes the list,<ul>(or<ol>withordered: true) forh2andh3, and nothing for a page with no headings, so an element written around the call is left behind empty. Guard it:{% set list = toc(content, { to: 4, ordered: true }) %}{% if list %}<nav class="toc">{{ list | safe }}</nav>{% endif %}in Nunjucks, which is eleventy-plugin-nesting-toc's<nav class="toc">, ordered lists andh2toh4. In Liquid:{% assign list = content | toc: to: 4, ordered: true %}{% if list != "" %}<nav class="toc">{{ list }}</nav>{% endif %}. - Some of Eleventy's built-in filters aren't there:
log,slug,getCollectionItem,getCollectionItemIndexandinputPathToUrlare errors until you define them (ssqch scoutwrites the first, third and fourth into the draft, and says how to portslug).getPreviousCollectionItemandgetNextCollectionItemwork. urlgives the URL back as written. Eleventy's also tidied it (a/../b/becameb/,./zbecamez). A link that counted on that needs writing out.- Data strings aren't templates. With Eleventy's
dataTemplateEngine, a data file could say"{{ '/about/' | url }}"; in ssqch it prints as written. Write/about/, or use acomputedvalue or a.data.jsfile. - Code fences mark lines with braces, counted from 1: the syntax-highlight plugin's
```js/1(the second line) is```js {2}in ssqch. Left as it is,js/1is a language ssqch doesn't have, so the block isn't highlighted, and withhighlighton the build warns (a `js/1` fence is plain text). Search the content for fences like it, or convert them as they're read (below). .lengthworks in Nunjucks, on lists and strings, as in Eleventy ({{ collections.post.length }});| lengthis the Jinja way and does the same.- A data file can start with a byte-order mark (SQL Server's and Excel's exports do): ssqch skips it in JSON, YAML, TOML, JavaScript and templates, as Node does.
- A folder of full-size photos is what
imagePlugin()fromssqch/imageis for: every<img>gets sized, modern-format copies in a<picture>, andimage()in a data file gives the URLs and dimensions without markup. - A printed date is ISO 8601 (
2024-06-01T00:00:00.000Z), not JavaScript'sDate.toString(), which depends on the machine's time zone. Format dates with a filter. - Markdown differs from markdown-it in a few places: bare domains like
example.comaren't links (onlyhttps://andwww.URLs are, as on GitHub) unlessmarkdown: { autolinks: "fuzzy" }, and withindentedCode: false, indented HTML renders as HTML (markdown-it wraps it in<p>). markdown-it'sbreaksand markdown-it-implicit-figures aremarkdown: { breaks: true, figures: true }(markdown-it's habits);ssqch scoutcarries them,linkifyandtypographerinto the draft config. - The layout is chosen before
computedruns. A computedlayoutthat's plain text (eleventyComputed: { layout: "article" }) is used; one that depends on the page is an error. Set it in the front matter or a data file. computeddoesn't seecollections. Build lists that need collections in a filter or a collection instead.- Includes come from
_includes(and themes), not from the project root as in Eleventy's Nunjucks. To show a source file in a page, read it in a filter:filters: { readFile: (p) => fs.readFileSync(p, "utf8") }. - Filters get your real objects, as in Eleventy, not copies: a filter that sorts or changes what it's given changes it for the pages rendered after it. Copy first (
[...posts].sort()). Data that refers to itself (nav items whoseprevandnextpoint at each other) is fine. {#id}at the end of a Markdown line is a heading attribute, not a Nunjucks comment, even though Markdown runs through Nunjucks or Jinja first.- markdown-it-anchor's ids are
markdown: { headingIds: "markdown-it-anchor" }(What’s new?iswhat%E2%80%99s-new%3F). Itstabindex="-1"and permalink are a heading hook's (below).
Prism and permalink markup with ssqch's Markdown
When you move from markdown-it to ssqch's Markdown and the site's CSS or scripts expect the old markup, two render hooks write the elements around the content. classes: "prism" keeps Prism's class names, so its theme still applies. The tokens are cut by ssqch's grammars, so a few spans differ from Prism's: this keeps the look and the structure, not the bytes (for the bytes, keep markdown-it).
// ssqch.config.js
import { safe } from "ssqch";
export default {
markdown: {
headingIds: "markdown-it-anchor",
highlight: { classes: "prism", css: false },
// Eleventy's ```js/1,3-4, counted from 0, as ssqch's ```js {2,4-5}, from 1.
preprocess: (source) => source.replace(/^([ \t]*(?:```+|~~~+)[\w+#-]+)\/([\d,\- ]+)$/gm, (_, fence, lines) => `${fence} {${lines.replace(/\d+/g, (n) => Number(n) + 1).replaceAll(" ", "")}}`),
},
// The syntax-highlight plugin's lineSeparator: "<br>".
filters: { brLines: (html) => safe(String(html).replace(/\n$/, "").replaceAll("\n", "<br>")) },
};
The fence hook is where the plugin's preAttributes and codeAttributes go: write them on the <pre> and the <code> (here tabindex="0").
{# _includes/hooks/fence.njk #}
{%- if fence.lang -%}
<pre class="language-{{ fence.lang }}" tabindex="0"><code class="language-{{ fence.lang }}">{{ (fence.highlighted or (fence.code | escape)) | brLines }}</code></pre>
{%- else -%}
<pre><code>{{ fence.code }}</code></pre>
{%- endif %}
The heading hook writes markdown-it-anchor's tabindex and, here, its linkInsideHeader permalink with the # after the text. Copy the class and symbol your config gave it:
{# _includes/hooks/heading.njk #}
<h{{ heading.level }} id="{{ heading.id }}" tabindex="-1">{{ heading.content | safe }} <a class="header-anchor" href="#{{ heading.id }}" aria-hidden="true">#</a></h{{ heading.level }}>
aria-hidden="true"is the one thing added to the plugin's markup: it keeps the#out ofpage.headings, and so out oftoc().- Without
lineSeparator: "<br>"(the plugin's default is a newline), keepbrLinesand take its.replaceAll(...)out: it still drops the last newline, as the plugin does. - Marked lines: with
classes: "prism", a marked line is the plugin's<mark class="highlight-line highlight-line-active">. The plugin also wraps the other lines of such a block in<span class="highlight-line">, and ssqch doesn't. Its added and removed lines (js/1/3) have no equivalent. - The cost: two templates and a filter of your own to maintain, which keep working until you change your mind about the markup.
Moving with identical output first
A big site moves most safely in two steps: first the same pages, byte for byte, then ssqch's own features one at a time. For the first step, keep Eleventy's template libraries and let ssqch do the rest (finding pages, the data cascade, pagination, collections, layouts, transforms, writing):
- Markdown: your markdown-it as it is,
engines: { md }(the instance you gavesetLibrary("md", ...)), andmarkdownEngine: "liquid", since Eleventy runs Markdown through Liquid first. Indented code blocks depend on the Eleventy version: Eleventy 3 turns them off in every markdown-it, a site's own included (md.disable("code")in your instance, for the same output), Eleventy 2 only in its own, and Eleventy 1 leaves them on.cache: truekeeps what it renders betweenssqch serve's rebuilds (Your own Markdown library). - Liquid and Nunjucks: ssqch's Liquid is liquidjs, as Eleventy's is, and its Nunjucks a fork of Nunjucks, so most pages match as they are. Its Liquid follows Ruby's in a few places, as Jekyll's does (math on text,
split);ssqch diffshows the pages that differ. - Front matter strings:
permalinkandcomputedstrings never go through an engine of your own: they render with ssqch's template language (for a.mdpage, themarkdownEngine), so your markdown-it never sees them. - Install what Eleventy brought along: liquidjs, nunjucks, gray-matter and luxon came with
@11ty/eleventy, and a site's data files often import them without listing them. Pin the versions Eleventy had (npm ls liquidjs nunjucks), since the output depends on them. - Plugins' filters, as they were: the RSS plugin's are its exports (
const rss = require("@11ty/eleventy-plugin-rss"), thenfilters: { absoluteUrl: rss.absoluteUrl, htmlToAbsoluteUrls: (html, base) => (html ? rss.convertHtmlToAbsoluteUrls(html, base, { closingSingleTag: "slash" }) : ""), rssDate: rss.dateToRfc3339 }), and eleventy-navigation's isfindNavigationEntries(above). ssqch's ownabsoluteUrl(url, base)is on every site already, with the site'sbasein front, sorss.absoluteUrlis only for Eleventy's answer to the letter. - Slugs: keep Eleventy's filters, not just their names.
npm install @sindresorhus/slugifyandfilters: { slugify: (text) => slugify(String(text), { decamelize: false }) }is Eleventy 3'sslugify, and takes the built-in's place. Itsslugis the olderslugifypackage, which keeps.and spells200%as200percent:npm install slugify, thenimport slugifyPackage from "slugify"andfilters: { slug: (text) => slugifyPackage(String(text), { lower: true }) }. For heading ids made with that package (a markdown-it-anchorslugifyoption), give it toheadingIdstoo:markdown: { headingIds: (text) => slugifyPackage(text, { lower: true }) }makes## 200% More Pine Cones#200percent-more-pine-cones. - Unclosed elements and the minifier: html-minifier-terser closes what a layout left open (
<main><section></main>comes out with its</section>), andminifyPlugin()leaves it as written. It leaves out end tags HTML lets you skip too, such as</p>and</li>, which are harmless but show inssqch diff. Browsers often hide the mistake, so it can be years old. Close the elements in the layout, whichssqch diffwill point you to, or run html-minifier-terser as a transform until you do (Packages). - Dates printed bare:
{{ date }}isDate.toString()in Eleventy (Mon Mar 08 2021 00:00:00 GMT+0000 (Coordinated Universal Time)withTZ=UTC) and ISO 8601 in ssqch. To match first, a transform puts Eleventy's text back (below); then format each date in its template ({{ date | dateformat("iso") }}), which also stops the page depending on the build machine's time zone, and delete the transform.ssqch diffcounts the two forms as dates. - The same time zone on both sides:
ssqch baselinebuilds Eleventy's copy withTZ=UTC, so build withTZ=UTC ssqch buildtoo. A site's owntoLocaleDateString, luxon without a zone and the transform below all read it. - Minify last: compare with both minifiers off until
ssqch diffsaysNo differences, then turn them on and look at what--exactshows. What's left is easier to read before every page is one line. - Pages with the same date (every undated page, with
SOURCE_DATE_EPOCHor a baseline's pinned times) sort by path, folder by folder; Eleventy compares the paths as text, soabout-us.mdcomes beforeabout/index.mdthere and after it here. For Eleventy's order in a list that shows it (a sitemap overcollections.all), sort in the template or define the collection:collections: { all: (pages) => [...pages.all()].sort((a, b) => a.date - b.date || (a.inputPath < b.inputPath ? -1 : a.inputPath > b.inputPath ? 1 : 0)) }. - Undated pages' dates: Eleventy gives them the file's creation time, so a sitemap's
<lastmod>is the checkout's time and changes on every clone.ssqch baselinepins file times to the commit's; setSOURCE_DATE_EPOCH=$(git log -1 --format=%ct)forssqch build, and the two agree. - Compare bytes:
ssqch diff --exact. Without--exact, whitespace between tags, image ids and how tags are written (attribute order, quotes, entities) are ignored. With it, image names differ wherever ids do (--ignore '/img/[A-Za-z0-9_-]{10}-'leaves the ids out), and eleventy-img's transform rewrote every HTML page as it went (<script defer>came out as<script defer="">), which ssqch doesn't.
The transform for bare dates changes ISO timestamps in the text of HTML pages, and leaves the quoted ones (datetime="...", JSON-LD) alone:
export default {
transforms: {
eleventyDates: (content, page) =>
page.outputPath.endsWith(".html")
? content.replace(/(?<!["'=])\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\b(?!["'])/g, (iso) => new Date(iso).toString())
: content,
},
};
An ISO timestamp a page meant to print as text changes too, and a bare date that Eleventy printed inside an attribute or a script stays ISO. ssqch diff shows both.
Then move one feature at a time to ssqch's (Markdown, highlighting, minifying, the table of contents), with ssqch diff after each.
Keeping markdown-it
A site whose markup comes from markdown-it and its plugins can keep all of it. This config gave the same bytes as Eleventy 3.1.8 (ssqch diff --exact) for a page with a permalink anchor, a ::: note container, breaks, and Prism fences with marked lines, using markdown-it 14, markdown-it-anchor 9, markdown-it-container 4 and the syntax-highlight plugin 5.0.2:
// ssqch.config.js
import prismHighlighter from "@11ty/eleventy-plugin-syntaxhighlight/src/markdownSyntaxHighlightOptions.js";
import markdownIt from "markdown-it";
import anchor from "markdown-it-anchor";
import container from "markdown-it-container";
import { defineConfig } from "ssqch";
const md = markdownIt({ html: true, breaks: true })
.use(anchor, { permalink: anchor.permalink.linkInsideHeader({ symbol: "#", class: "bookmark", placement: "after" }) })
.use(container, "note");
// What Eleventy did to the library you gave setLibrary("md", ...).
md.disable("code"); // Eleventy 3
md.set({ highlight: prismHighlighter({ lineSeparator: "<br>", preAttributes: { tabindex: 0 } }) }); // the plugin's options (below)
export default defineConfig({
markdownEngine: "liquid",
engines: { md: { render: (source) => md.render(source), cache: true } },
filters: { markdown: (text) => md.render(String(text ?? "")) },
});
- Install what the config imports (
npm install -D markdown-it markdown-it-anchor ...), at the versions the old site had (npm ls markdown-it, before removing@11ty/eleventy). Keep@11ty/eleventy-plugin-syntaxhighlightinstalled for its highlighter: it brings Prism with it, and works without Eleventy. - The highlighter's options are the ones you gave the plugin, with one difference: called this way, it joins lines with
<br>, where the plugin's own default is a newline. If your Eleventy config set nolineSeparator, passlineSeparator: "\n". - One line covers every
.mdpage:engines: { md }replaces ssqch's Markdown, so no folder needs arenderof its own. ssqch'smarkdownoptions, containers and render hooks no longer apply to those pages. - The
markdownfilter stays ssqch's unless you define one, as above, so a front-matter string rendered with it matches the page around it. env: the instance itself (engines: { md }) gets the page's data asenv, as Eleventy gave it. The wrapper withcache: truedoesn't, and caching is only right when the output depends on the source alone.- Speed: the library runs on Node, as it did. On a generated 500-page site of prose and code (an Apple silicon laptop, Node 26),
ssqch buildtook about 0.2 s with markdown-it and Prism. ssqch's own Markdown withhighlight: truetook about 1 s with no.cache/yet, and 0.11 s with it.
Packages
ssqch runs a site's JavaScript on Node, so every package that worked with Eleventy works here, at Node's speed, with nothing to port. A few notes:
| Package | On ssqch | Instead |
|---|---|---|
| html-minifier, html-minifier-terser | Works, as a transform of your own (transforms: { minify: async (content, page) => page.outputPath.endsWith(".html") ? await minify(content, options) : content }). It gives Eleventy's bytes, which is what you want while the move is checked with ssqch diff --exact | minifyPlugin() from ssqch/minify, several times faster, with bytes of its own; switch when the bytes stop mattering |
| cheerio, @lit-labs/ssr | Work | page.headings, toc() and transforms on strings are cheaper for a little work |
| Anything that drives a browser (Playwright, Puppeteer) | Works, but a build that opens a browser is slow | A beforeBuild run: step that renders once, or a small local server your config fetches |
Pages render one at a time on one thread (there are no worker threads), so if a build is much slower than with Eleventy, time the filters and transforms with console.time: one slow package is usually most of it.
Checking the move
Build the old site with Eleventy and the new one with ssqch, and compare the two output folders. ssqch baseline makes Eleventy's build from fresh copies with the clock pinned, three times, and says what changes by itself:
ssqch baseline "npx @11ty/eleventy" --commit <the commit before the import>
ssqch build
ssqch diff .cache/ssqch/baseline/ref-1 dist # or ref-common, when the builds vary
It lists the URLs that were added and removed and what changed on each page, ignoring whitespace between tags, fingerprinted file names, eleventy-img's and imagePlugin()'s image ids, and markup browsers read the same (attribute order, defer="defer", <br/>, '); --ignore <regex> drops differences you expect (a generator meta tag, say). The link checker (linksPlugin()) catches pages and anchors that moved, and a schemas entry catches front matter that didn't survive the trip.
Only dates changed: a file whose changes are all dates or years is noted only dates changed (2024 -> 2026) (a group of pages with the same change lists its lines instead, and --format json has onlyDates: true for each file), and the summary says All 3 changed files differ only in dates or years, or 3 of the 40 changed files when there's more to look at. In a move from Eleventy it's usually a page with no date, which takes its file's time (above): give it one, set dateFallback: "git", or print the build's year for a copyright line. A bare Date.toString() against ISO 8601 counts as a date change too (Dates that changed).
If the site has a second build tool (Gulp, webpack, PostCSS) writing into the same folder, keep it for the first step: build with ssqch build && <the tool> (ssqch never touches files it didn't write) and give ssqch baseline both commands (ssqch baseline "npx @11ty/eleventy && npx gulp build"). ssqch needs Node 22.18 or newer, so a site pinned to an older Node moves its other tools too: build the old site once on the new Node and compare it with the old Node's build, so a difference the new Node makes isn't blamed on ssqch. When ssqch baseline says files vary, three builds show that they do, not which version is usual: --runs 20 (or more) counts each version, and .cache/ssqch/baseline/ref-common has each file's most common one to compare with.
ssqch scout drafts the mechanical renames above for you; see Scouting. For the whole loop as steps a coding agent can follow (reference builds, the biggest group of differences first, when to stop), see Moving a site with an agent.