* feat(plugins): v5 plugin system * feat(plugins): explorer as community plugin * feat(plugins): graph as community plugin * chore: update package-lock.json * chore: update package-lock.json * docs: updated plugin-specific docs * chore: update package-lock.json * chore: update package-lock.json * chore: update package-lock.json * Implement Git-based plugin system with dogfooding for community plugins - Remove npm dependencies for @quartz-community/* plugins - Add gitLoader.ts for installing plugins from GitHub - Update quartz.layout.ts to import from .quartz/plugins/ - Add install-plugins.ts script for prebuild hook - Add .quartz/ to .gitignore * Add comprehensive Git-based plugin CLI with lockfile support - Create quartz.lock.json format for tracking exact plugin commits - Add 'npx quartz plugin' commands: install, add, remove, update, list, restore - Plugin state is fully reproducible via lockfile - No npm dependencies required for community plugins * Fix TypeScript errors in git-installed plugins - Install @quartz-community/types as devDependency - Fix plugin imports to define types locally - Fix search inline script fetchData bug - Format code with prettier * fix(types): install types from github * docs: updated plugin-specific docs * Update Dockerfile and add CI/CD documentation - Add plugin install step to Dockerfile - Create docs/ci-cd.md with pipeline configuration guide * Update GitHub Actions workflows for v5 branch and Git-based plugins - Change branch references from v4 to v5 - Add plugin caching to speed up builds - Use 'npx quartz plugin install' instead of 'restore' - Update Docker workflow branch trigger * Update quartz.lock.json with fixed plugin versions * fix(docker): install command * docs: add plugin migration analysis document Comprehensive analysis of which Quartz v4 components and plugins can be migrated to separate repositories, including: - Component analysis (25 components) - Plugin analysis (transformers, emitters, filters) - Migration strategies for different plugin types - Lessons learned from Explorer/Graph/Search migrations - Recommended migration order * chore: updated plugins * chore: updated plugins * chore: updated dependencies * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: tsconfig * feat: build installed plugins * chore: updated plugins * chore: updated plugins * chore: update explorer plugin with duplication fix * docs: Quartz v5 * chore: update graph plugin with navigation fix * fix: update explorer plugin with toggle fix * fix: update explorer plugin - ensure toggle buttons always work * fix: create plugin components once to prevent duplicate script registration * chore: updated plugins * chore: updated plugins * feat: migrate 7 feature components to community plugins (Phase B) Migrate ArticleTitle, TagList, PageTitle, Darkmode, ReaderMode, ContentMeta, and Footer from internal components to community plugins. Update layout to use Plugin.X() pattern, remove internal component files and their styles/scripts. Add MIGRATION_TASKS.md documenting the full migration roadmap. * chore: updated plugins * refactor: delete 6 internal component duplicates (Phase A) Remove Backlinks, Breadcrumbs, RecentNotes, Search, TableOfContents, Comments, and OverflowList — all replaced by community plugins. Delete associated styles (6) and scripts (3). Switch layout to use Plugin.Breadcrumbs() instead of Component.Breadcrumbs(). * refactor: unify QuartzComponent type to structural interface (Phase C) - Changed QuartzComponent from ComponentType<QuartzComponentProps> to callable type ((props: QuartzComponentProps) => any) - Added optional displayName property for better debugging - Removed ComponentType import from preact - Removed all 13 'as QuartzComponent' type casts from quartz.layout.ts - Community plugin components now directly assignable without casts * feat: add PageType plugin infrastructure (Phase D Step 4) * feat: add PageTypePluginEntry for cross-boundary type compatibility Introduce PageTypePluginEntry with never[] parameter types to accept both internal and community PageType plugins in config arrays without casts, working around branded FullSlug contravariance mismatch. * refactor: update dispatcher to cast PageTypePluginEntry at boundary Add getPageTypes() helper that casts config's PageTypePluginEntry[] to QuartzPageTypePluginInstance[] in one place. Cast VirtualPage.slug to FullSlug at emitPage/defaultProcessedContent call sites. * feat: integrate community PageType plugins (Phase D Step 6) Replace old page-rendering emitters with PageTypeDispatcher emitter and pageTypes array. Restructure quartz.layout.ts from three separate exports to unified layout object with defaults and byPageType record. Install content-page, folder-page, tag-page community plugins. * refactor: delete old page-rendering emitters Remove ContentPage, FolderPage, TagPage, and NotFoundPage emitters now replaced by community PageType plugins and the PageTypeDispatcher. * refactor: remove migrated page body components Delete Content, FolderContent, TagContent page components now provided by community PageType plugins. Update components barrel export. * fix: update lockfile to fixed folder-page and tag-page commits Points to commits that remove duplicate PageList/SortFn re-exports, fixing TS2300 duplicate identifier errors in generated plugin index. * chore: updated plugins * fix: populate ctx.trie in PageTypeDispatcher before rendering Components like FolderContent depend on ctx.trie for folder hierarchy. The dispatcher now lazily initializes it via trieFromAllFiles in emit and force-rebuilds it in partialEmit to reflect file changes. * chore: update lockfile to fixed folder-page commit * chore: updated plugins * chore: update explorer plugin to fix SPA folder navigation * feat: extract transformers to community plugins and fix type compatibility - Delete 12 internal transformer files (keep FrontMatter as internal) - Switch quartz.config.ts to use ExternalPlugin.* for all transformers - Align branded types with @quartz-community/types (_brand, FullSlug etc.) - Add vfile DataMap augmentations for fields from extracted transformers - Update all 29 plugins to @quartz-community/types v0.2.1 * Migrate filters to external plugins (remove-draft, explicit-publish) Delete internal RemoveDrafts and ExplicitPublish filter implementations, install them as community plugins, and update quartz.config.ts to use ExternalPlugin.RemoveDrafts(). * Migrate emitters to external plugins (alias-redirects, cname, favicon, content-index, og-image) * refactor: remove inline scripts/styles migrated to plugins Delete dead code: callout, checkbox, mermaid inline scripts and styles are now bundled by the obsidian-flavored-markdown plugin. Clipboard script and styles moved to the syntax-highlighting plugin. listPage.scss was unreferenced. Body.tsx simplified to a pure layout wrapper. * refactor: consolidate utils to re-export from @quartz-community/utils * fix: use dangerouslySetInnerHTML for inline CSS to prevent HTML-escaping Preact was escaping & characters in SCSS-compiled CSS (e.g. & nesting) into &, breaking CSS rules. Using dangerouslySetInnerHTML bypasses the escaping, matching how browsers expect style element content. * chore: update plugins with inline script transpilation fix * chore: updated plugins * docs: update plugin API sections for v5 community plugins * docs: rewrite documentation for v5 plugin system Update feature docs, hosting, CI/CD, getting started, configuration, layout, architecture, creating components, making plugins, and migration guide to reflect the v5 community plugin architecture. * docs: fix outdated v4 references in documentation * chore: remove completed migration planning docs * chore: updated plugins * chore: cleanup * chore: cleanup * chore: bump version to 5.0.0 * chore: updated dependencies * feat: integrate CanvasPage plugin with types, assets, config, layout, and documentation * chore: updated dependencies * chore: updated dependencies * chore: updated linter * chore: update canvas-page plugin to c942fcb * chore: updated plugins * chore: update canvas-page plugin to f88f1b9 * chore: updated plugins * chore: update canvas-page plugin to 079304c * chore: updated plugins * chore: canvas layout * chore: update canvas-page plugin to 38d49e1 * chore: updated plugins * chore: update canvas-page plugin to 505c099 * chore: updated plugins * chore: updated plugins * fix: Obsidian flavored markdown * fix: Obsidian flavored markdown * fix: Obsidian flavored markdown * chore: cleanup * chore: updated plugins * feat: configuration files * feat: Quartz TUI * feat(tui): YAML configuration * chore: tsup * chore: tsup * feat: support array categories in plugin manifests Plugins like note-properties export both transformer and component functionality. Allow PluginManifest.category to be a single value or an array, with config-loader resolving to the first processing category (transformer/filter/emitter/pageType) for dispatch. * refactor: remove built-in FrontMatter transformer Frontmatter processing is now handled by the note-properties plugin, which provides the same YAML/TOML parsing plus link extraction and a visual properties panel. The built-in transformer is no longer needed. * feat: add note-properties plugin to default configuration Register note-properties as the first plugin (order 5) in both the user config and the default config. Placed in beforeBody layout zone with priority 15 (between article-title at 10 and content-meta at 20). * docs: add plugin management strategy and syncer v5 notes Document the plugin management system design decisions and provide implementation guidance for the Quartz Syncer v5 integration. * feat: add bases-page plugin to default configuration Enable Obsidian Bases (.base) file support with bases page type and layout entry in both user and default config. * docs: update syncer notes with bases-page, note-properties, and spacer Add all three new plugins to the quick reference table (40 total). Add content, canvas, and bases page types to byPageType documentation. * chore: updated plugins * fix: update CI to Node 24 and regenerate lockfiles for clean install * fix: resolve type errors for CI checks * chore: updated plugins * chore: updated plugins * fix: plugin mapping from configuration * fix: CI * fix: CI * docs: rewrite Frontmatter documentation for note-properties plugin * chore: updated plugins * docs: Quartz v5 * chore: updated plugins * chore: updated plugins * refactor: extract TUI to standalone plugin repository * chore: linting * docs: Quartz v5 * feat: update and upgrade commands * chore: updated plugins * chore: updated plugins * chore: cleanup * chore: cleanup * chore: cleanup * chore: cleanup * chore: cleanup * fix: layout group priority * fix: view classes * fix: include virtual pages in content index for explorer visibility * docs: add board, gallery, and cards view examples to navigation page * chore: updated plugins * fix: include virtualPages in worker serializable build context * fix: set relativePath on virtual pages to prevent explorer crash * fix: exclude 404 * fix(links): virtual page links * fix(links): virtual page transclusion * docs: architecture overview * fix: only call scripts one per page * fix: type error in component registry instantiate method * fix: left layout order * fix(layout): remove tag-list by default * docs(plugins): updated plugin list defaults * fix(layout): priorities * feat: add PageFrame system for custom page layouts * feat: integrate PageFrame into rendering pipeline * feat: add frame resolution to page type dispatcher and config loader * style: add CSS grid overrides for full-width and minimal page frames * feat: set minimal frame for 404 and update canvas-page plugin * docs: add PageFrame system to architecture overview * fix: wrap frame.render() in array to satisfy Body children type * chore: format * fix: use absolute asset paths for 404 page so it works in subdirectories * fix(layout): priorities * docs: page frames * feat: add FrameRegistry for plugin-provided page frames Plugins can now register custom page frames via their manifest's 'frames' field. Frames are loaded alongside components during plugin initialization and resolved by name at render time with fallback to built-in frames. * feat(layout): page frames * fix(layout): linting * fix: inject frame CSS into page so plugin-provided frames render correctly * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * docs: canvas * chore: updated plugins * chore: updated plugins * chore: updated plugins * feat: add TreeTransform hook, fix multi-category plugins, and resolve cross-plugin dependencies - Add TreeTransform type and treeTransforms hook to pageType plugins, enabling render-time HAST tree mutations (e.g. bases-page inline codeblock resolution) - Fix config-loader to push multi-category plugins into ALL matching processing buckets instead of only the first match - Add side-effect import for component-only plugins so view registrations (e.g. leaflet-map via globalThis ViewRegistry) execute at load time - Add npm prune --omit=dev and cross-plugin peer dependency symlinking to buildPlugin() to prevent duplicate-singleton issues from nested node_modules * chore: format * chore: test docs * chore: updated plugins * fix: prevent HTML-escaping of inline style and script content in htmlToJsx Add dangerouslySetInnerHTML overrides for <style> and <script> elements so that CSS/JS injected by tree transforms is not HTML-escaped during preact-render-to-string serialization. * chore: update plugin lockfile for htmlToJsx migration * chore: update leaflet-map plugin (fix deferred L.Control) * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: updated plugins * chore: test npx quartz upgrade * feat(templates): add obsidian, ttrpg, blog templates * docs: move bases * docs: removed leaflet demo * feat(cli): configure baseUrl during create * docs: updated cli commands * docs: updated documentation for v5 * feat(cli): prune and resolve * chore: rebuild lockfile * docs: cli documentation * docs: plugin development and setup guide * chore: deleted redundant files * fix(build): fallback config * chore: updated lockfile * docs: removed outdated v3 setup * feat(cli): allow non-default branch plugins * docs: install branch commands * feat(cli): allow local plugins * docs: install local commands * feat: add render event type and listener for in-place DOM re-initialization * docs: add EncryptedPages plugin documentation * docs: add encrypted pages live demo page - New password-protected demo page (password: quartz) showing the plugin in action - Link to demo from EncryptedPages plugin page with password hint callout * feat: add encrypted-pages plugin to all templates - Enabled by default in default, obsidian, and ttrpg templates - Disabled by default in blog template * chore: updated plugins * chore: updated layouts * chore: updated plugins * feat: stacked pages * feat: added stacked page panes * docs: touch-ups
12 KiB
| title |
|---|
| Architecture |
Quartz is a static site generator. How does it work?
This question is best answered by tracing what happens when a user (you!) runs npx quartz build in the command line:
On the server
- After running
npx quartz build, npm will look atpackage.jsonto find thebinentry forquartzwhich points at./quartz/bootstrap-cli.mjs. - This file has a shebang line at the top which tells npm to execute it using Node.
bootstrap-cli.mjsis responsible for a few things:- Parsing the command-line arguments using yargs. The
pluginsubcommand is also handled here for managing external plugins. - Transpiling and bundling the rest of Quartz (which is in Typescript) to regular JavaScript using esbuild. The
esbuildconfiguration here is slightly special as it also handles.scssfile imports using esbuild-sass-plugin v2. Additionally, we bundle 'inline' client-side scripts (any.inline.tsfile) that components declare using a customesbuildplugin that runs another instance ofesbuildwhich bundles for the browser instead ofnode. Modules of both types are imported as plain text. - Running the local preview server if
--serveis set. This starts two servers:- A WebSocket server on port 3001 to handle hot-reload signals. This tracks all inbound connections and sends a 'rebuild' message a server-side change is detected (either content or configuration).
- An HTTP file-server on a user defined port (normally 8080) to serve the actual website files.
- If the
--serveflag is set, it also starts a file watcher to detect source-code changes (e.g. anything that is.ts,.tsx,.scss, or packager files). On a change, we rebuild the module (step 2 above) using esbuild's rebuild API which drastically reduces the build times. - After transpiling the main Quartz build module (
quartz/build.ts), we write it to a cache file.quartz-cache/transpiled-build.mjsand then dynamically import this usingawait import(cacheFile). However, we need to be pretty smart about how to bust Node's import cache so we add a random query string to fake Node into thinking it's a new module. This does, however, cause memory leaks so we just hope that the user doesn't hot-reload their configuration too many times in a single session :)) (it leaks about ~350kB memory on each reload). After importing the module, we then invoke it, passing in the command line arguments we parsed earlier along with a callback function to signal the client to refresh.
- Parsing the command-line arguments using yargs. The
- In
build.ts, we start by installing source map support manually to account for the query string cache busting hack we introduced earlier. Then, we start processing content:- Clean the output directory.
- Recursively glob all files in the
contentfolder, respecting the.gitignore. - Parse the Markdown files.
- Quartz detects the number of threads available and chooses to spawn worker threads if there are >128 pieces of content to parse (rough heuristic). If it needs to spawn workers, it will invoke esbuild again to transpile the worker script
quartz/worker.ts. Then, a work-stealing workerpool is then created and batches of 128 files are assigned to workers. - Each worker (or just the main thread if there is no concurrency) creates a unified parser based off of the plugins defined in the configuration.
- Parsing has three steps:
- Read the file into a vfile.
- Applied plugin-defined text transformations over the content.
- Slugify the file path and store it in the data for the file. See the page on paths for more details about how path logic works in Quartz (spoiler: its complicated).
- Markdown parsing using remark-parse (text to mdast).
- Apply plugin-defined Markdown-to-Markdown transformations.
- Convert Markdown into HTML using remark-rehype (mdast to hast).
- Apply plugin-defined HTML-to-HTML transformations.
- Quartz detects the number of threads available and chooses to spawn worker threads if there are >128 pieces of content to parse (rough heuristic). If it needs to spawn workers, it will invoke esbuild again to transpile the worker script
- Filter out unwanted content using plugins.
- Emit files using plugins.
- Gather all the static resources (e.g. external CSS, JS modules, etc.) each emitter plugin declares.
- Emitters that emit HTML files do a bit of extra work here as they need to transform the hast produced in the parse step to JSX. This is done using hast-util-to-jsx-runtime with the Preact runtime. Finally, the JSX is rendered to HTML using preact-render-to-string which statically renders the JSX to HTML (i.e. doesn't care about
useState,useEffect, or any other React/Preact interactive bits). Here, we also do a bunch of fun stuff like assemble the page layout fromquartz.config.yaml, assemble all the inline scripts that actually get shipped to the client, and all the transpiled styles. The bulk of this logic can be found inquartz/components/renderPage.tsx. Other fun things of note:- CSS is minified and transformed using Lightning CSS to add vendor prefixes and do syntax lowering.
- Scripts are split into
beforeDOMLoadedandafterDOMLoadedand are inserted in the<head>and<body>respectively.
- Finally, each emitter plugin is responsible for emitting and writing it's own emitted files to disk.
- If the
--serveflag was detected, we also set up another file watcher to detect content changes (only.mdfiles). We keep a content map that tracks the parsed AST and plugin data for each slug and update this on file changes. Newly added or modified paths are rebuilt and added to the content map. Then, all the filters and emitters are run over the resulting content map. This file watcher is debounced with a threshold of 250ms. On success, we send a client refresh signal using the passed in callback function.
On the client
- The browser opens a Quartz page and loads the HTML. The
<head>also links to page styles (emitted topublic/index.css) and page-critical JS (emitted topublic/prescript.js) - Then, once the body is loaded, the browser loads the non-critical JS (emitted to
public/postscript.js) - Once the page is done loading, the page will then dispatch a custom synthetic browser event
"nav". This is used so client-side scripts declared by components can 'setup' anything that requires access to the page DOM.- If the SPA Routing is enabled in the configuration, this
"nav"event is also fired on any client-navigation to allow for components to unregister and reregister any event handlers and state. - If it's not, we wire up the
"nav"event to just be fired a single time after page load to allow for consistency across how state is setup across both SPA and non-SPA contexts. - A separate
"render"event can be dispatched when the DOM is updated in-place without a full navigation (e.g. after content decryption). Components that attach listeners to content elements should listen for both"nav"and"render".
- If the SPA Routing is enabled in the configuration, this
Plugin System
Page types define how a category of pages is rendered. They are configured in the pageTypes array in quartz.config.yaml.
Quartz v5 introduces a community plugin system. Plugins are standalone Git repositories that are cloned into .quartz/plugins/ and re-exported through an auto-generated index file at .quartz/plugins/index.ts.
Plugin Types
There are now four plugin categories:
- Transformers: Map over content (parse frontmatter, generate descriptions, syntax highlighting)
- Filters: Filter content (remove drafts, explicit publish)
- Emitters: Reduce over content (generate RSS, sitemaps, alias redirects, OG images)
- Page Types: Define how pages are rendered. Each page type handles a specific kind of page (content notes, folder listings, tag listings, 404). The
PageTypeDispatcheremitter routes pages to the appropriate page type plugin based on the content.
Plugin Resolution
When npx quartz plugin add github:quartz-community/explorer is run:
- The repository is cloned into
.quartz/plugins/explorer/ - The plugin is built using
tsup(defined in each plugin'stsup.config.ts) - An auto-generated
.quartz/plugins/index.tsre-exports all installed plugins - The plugin's commit hash is recorded in
quartz.lock.json
Plugin CLI Commands
npx quartz plugin add github:quartz-community/<name>— Install a community pluginnpx quartz plugin update— Update all plugins to latest commitsnpx quartz plugin restore— Restore plugins from locked commits inquartz.lock.json(used in CI/CD)npx quartz plugin remove <name>— Remove an installed plugin
Plugin Structure
Each community plugin repository contains:
src/index.ts— Plugin entry point exporting the plugin functiontsup.config.ts— Build configuration using tsuppackage.json— Declares dependencies on@quartz-community/typesand@quartz-community/utils
The architecture and design of the plugin system was intentionally left pretty vague here as this is described in much more depth in the guide on making plugins.
Page Frames
Page frames control the inner HTML structure of each page. While the outer shell (<html>, <head>, <body>, #quartz-root) is always the same (required for SPA Routing), the frame determines how layout slots are arranged inside the page.
The frame system lives in quartz/components/frames/ and consists of:
types.ts— Defines thePageFrameandPageFramePropsinterfacesDefaultFrame.tsx— Three-column layout (left sidebar, center, right sidebar, footer)FullWidthFrame.tsx— No sidebars, single center columnMinimalFrame.tsx— No sidebars, no header/beforeBody, just content and footerregistry.ts—FrameRegistrysingleton for plugin-registered framesindex.ts—resolveFrame()function and built-in frame registry
Frame Registry
The FrameRegistry (quartz/components/frames/registry.ts) is a singleton that stores frames registered by community plugins. It mirrors the design of the ComponentRegistry. Plugins declare frames in their package.json manifest under the "quartz"."frames" field, and these are loaded by quartz/plugins/loader/frameLoader.ts during plugin initialization.
Frame Resolution
The rendering pipeline in quartz/components/renderPage.tsx delegates to the resolved frame's render() function. Frame resolution happens in the PageTypeDispatcher emitter (quartz/plugins/pageTypes/dispatcher.ts) using this priority:
- YAML config:
layout.byPageType.<name>.template - Plugin-registered frame: looked up by name in the
FrameRegistry - Built-in frame: looked up by name in the
builtinFramesmap - Fallback:
"default"
The active frame name is set as a data-frame attribute on the .page element, enabling frame-specific CSS overrides in quartz/styles/base.scss.
Plugin-Provided Frames
Community plugins can ship their own frames by exporting them from a ./frames subpath and declaring them in the plugin manifest. For example, the canvas-page plugin provides a "canvas" frame with a fullscreen layout and togglable sidebar. See making plugins#Providing Custom Frames for implementation details.
See layout#Page Frames for user-facing documentation and making plugins#Page Types for how to set frames in page type plugins.