Quartz's default og image plugin.
  • TypeScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-09 23:04:06 +01:00
.changeset chore: version package 2026-11-09 02:17:06 +00:00
.github/workflows ci: run ci.yml on the changesets version PR and report it as a commit status 2026-11-09 03:47:26 +01:00
src feat: useGeneratedDescription option, so defaultDescription can replace the generated excerpt (#2470) 2026-11-08 01:48:47 +01:00
test feat: useGeneratedDescription option, so defaultDescription can replace the generated excerpt (#2470) 2026-11-08 01:48:47 +01:00
types chore: centralize type declarations and standardize tooling config 2026-03-16 18:55:26 +01:00
.eslintrc.json chore: centralize type declarations and standardize tooling config 2026-03-16 18:55:26 +01:00
.gitignore chore: migrate to npm publishing 2026-07-23 09:07:27 +02:00
.prettierignore chore: centralize type declarations and standardize tooling config 2026-03-16 18:55:26 +01:00
.prettierrc Initial commit 2026-02-13 23:35:47 +01:00
CHANGELOG.md chore: version package 2026-11-09 02:17:06 +00:00
LICENSE Initial commit 2026-02-13 23:35:47 +01:00
package-lock.json chore: version package 2026-11-09 02:17:06 +00:00
package.json chore: version package 2026-11-09 02:17:06 +00:00
README.md docs(readme): Quartz 5.1 — npm install and config, correct options and defaults 2026-11-09 22:57:50 +01:00
tsconfig.json chore: migrate to npm publishing 2026-07-23 09:07:27 +02:00
tsup.config.ts fix: bundle JS deps while excluding native modules from bundling 2026-04-27 22:26:44 +02:00
vitest.config.ts fix: add passWithNoTests to vitest config 2026-03-09 03:21:30 +01:00

@quartz-community/og-image

Generates Open Graph social preview images for each page using Satori and Sharp.

Installation

npx quartz plugin add @quartz-community/og-image

Usage

This plugin is already enabled in the default quartz.config.yaml:

plugins:
  - source: "@quartz-community/og-image"
    enabled: true
    options:
      colorScheme: lightMode
      width: 1200
      height: 630
      defaultTitle: Untitled
      defaultDescription: No description provided
      useGeneratedDescription: true

baseUrl must be set in configuration: the image meta tags need absolute URLs and are not emitted without it. Each page gets an image at <slug>-og-image.webp; pages with a socialImage in their frontmatter are skipped.

The options that take functions (imageStructure, readingTimeText) need a TypeScript override:

import * as ExternalPlugin from "./.quartz/plugins";
import { myImage } from "./socialImage";

// Must be placed before loadQuartzConfig()
ExternalPlugin.CustomOgImages({
  imageStructure: myImage, // omit to keep the built-in design
  readingTimeText: (minutes) => `${minutes} min read`,
});

imageStructure receives a single object: { cfg, userOpts, title, description, fonts, fileData, iconBase64 }.

Configuration

Option Type Default Description
colorScheme "lightMode" | "darkMode" "lightMode" The color scheme to use for the generated images.
width number 1200 The width of the generated images.
height number 630 The height of the generated images.
defaultTitle string "Untitled" The title to use if a page has no title.
defaultDescription string "No description provided" The description to use if a page has no description.
useGeneratedDescription boolean true Use the generated description (the description plugin's excerpt) when the frontmatter has none. false shows defaultDescription instead.
readingTimeText (minutes: number) => string `${minutes} min read` Formats the reading time shown by the built-in design (TS override only).
imageStructure function built-in design A component that defines the structure of the generated image (TS override only).

The description on an image is, in order: the frontmatter's socialDescription, its description, the generated description (unless useGeneratedDescription is false), and finally defaultDescription.

excludeRoot is accepted but currently has no effect.

Documentation

See the Quartz documentation for more information.

License

MIT