Audit of the docs against 5.1 (release notes, core source, plugins) and fixes: - getting-started: 5.0 → 5.1 upgrade section (plugin doctor --fix, line breaks, heading ids, Bases 1.2, permalinks, frontmatter, CI, GFM before OFM), New in 5.1, git pull upstream v5, no redundant install steps - advanced: new plugin manifest reference (dependencies, defaultOrder, configSchema/optionSchema, deprecated, components…), making plugins (BuildCtx, emitters, page types, peer dependencies, imports), creating components (./components subpath, script loading, render/prefetch contract), capabilities, architecture, paths - cli: --directory is the content folder; build/sync flags and behaviour (sync force-pushes); plugin add from npm - configuration, layout, features and plugin pages: nested colors, built-ins, wikilinks/heading anchors, Obsidian compatibility (OFM 2.0), correct defaults and options, Bases 1.2, stacked pages, og-image v5 API; new pages for Excalidraw, TTRPG maps and themes
3.3 KiB
title
| title |
|---|
| Customizing Components |
In Quartz v4, components such as the footer lived in quartz/components/ and you customized them by editing their source. In v5, most components are configuration#Plugins, and Quartz runs their built code (dist/). The default plugins are npm packages in node_modules/@quartz-community/; plugins installed from Git live in .quartz/plugins/. Editing either copy is the wrong approach: changes to the source have no effect until it is rebuilt, and both are overwritten the next time the plugin is installed or updated.
There are four ways to change a component, from least to most effort. Try them in this order.
1. Options
Most components have options; each plugin's page under plugins/index lists them. Set them in quartz.config.yaml:
plugins:
- source: github:quartz-community/footer
enabled: true
options:
message: 'Licensed under <a href="/license">CC BY 4.0</a>'
links:
GitHub: https://github.com/you/your-site
or from the command line with npx quartz plugin config footer --set message="Hello" (see cli/plugin).
2. Placement
Where a component appears, in which order, on which page types and screen sizes is part of the layout, not the component: layout.position, layout.priority and layout.display per plugin, and layout.byPageType to drop or move components on some page types. See layout and layout-components.
3. Styles
Write your own styles in quartz/styles/custom.scss. The styles of Quartz, its plugins and themes are in CSS cascade layers and custom.scss is not, so your rules take precedence over theirs whatever their specificity. Find the element's classes with your browser's developer tools, then for example:
footer {
opacity: 1;
text-align: center;
& ul {
justify-content: center;
}
}
For site-wide colors and fonts, use the configuration#General Configuration first.
4. Your own copy of the plugin
When options and CSS are not enough (you want different markup or behavior), make your own copy of the plugin and use that instead:
-
Copy the plugin's repository (fork it on GitHub, or clone it) into a directory outside
.quartz/, e.g. next to your site:git clone https://github.com/quartz-community/footer.git ../my-footer. -
Change its source (for the footer,
src/components/Footer.tsx) and build it:npm install && npm run buildin that directory. -
Replace the plugin in your site with your copy:
npx quartz plugin remove footer npx quartz plugin add ../my-footerLocal plugins are symlinked into
.quartz/plugins/. After further changes, runnpm run buildin your copy again (ornpx quartz plugin install --latest, which rebuilds local plugins) and rebuild the site.
If you forked on GitHub, you can instead push your changes and add the fork with npx quartz plugin add github:you/my-footer, so your site builds in CI too. Note that a local path only works on machines that have that directory.
If you think others would want your change, consider opening a pull request against the original plugin, perhaps as a new option. To write a component from scratch, see creating components.