Welcome to Astro Jing
Astro Jing is a calm blog theme powered by Astro. This post will show you how to use it.
Features:
- Auto-generate post descriptions based on character count or up to the
<!-- more -->tag - Auto-expanding & collapsing table of contents
- Open Graph image generation
- Full-text search
- Syntax highlighting
- Math equations
- Internationalization (i18n)
- Comment systems (Giscus / Disqus)
- Sitemap & RSS feed
- Static site
- View the post as Markdown
Usage
git clone https://github.com/ziteh/astro-jing-theme.gitcd astro-jing-themepnpm ipnpm devMarkdown
Posts
By default, place your post .md files in the src/content/blog/ directory. Set CONTENT_DIR to use a different content root.
Frontmatter
The YAML frontmatter format for posts broadly compatible with Hexo, the default values for some fields can be changed in the site.ts configuration (with defaultFm prefix).
| Field | Description | Type |
|---|---|---|
title* | Post title (h1), also used as the metadata title. | string |
description | Post summary, auto-generated if not given. | string |
date* | Publish date | string in YYYY-MM-DDTHH:mm:ss |
updated | Updated date | string in YYYY-MM-DDTHH:mm:ss |
tags | Post tags | Array of strings, default: SITE.defaultFmTag |
categories | Post categories | Array of strings, default: SITE.defaultFmCategory |
draft | Mark as draft, excludes from production | boolean, default: false |
featured | Mark as featured post | boolean, default: false |
toc | Enable table of contents | boolean, default: SITE.defaultFmToc |
comments | Enable comments | boolean, default: SITE.defaultFmComments |
math | Enable math equations | boolean, default: SITE.defaultFmMath |
*: required
About
The Markdown for about page is: src/content/about.md.
about.md does not require frontmatter; it is recommended not to include an h1 (i.e. # Header).
Configuration
There are some settings that need to be adjusted before deployment.
site.ts
Basic site information and feature toggles.
| Field | Description | Example |
|---|---|---|
url* | Your site’s URL | https://username.github.io |
title* | Blog title | My Blog |
description* | Blog description | A personal blog |
author* | Blog author name | ZiTe |
postsPerHomepage | Posts to display per page (home) | 3 |
postsPerArchives | Posts to display per page (archives) | 10 |
postsPerAllPosts | Posts to display per page (posts) | 5 |
getDescriptionCount | Character count for auto-description | 150 |
getDescriptionMaxLines | Max lines to process for auto-description | 10 |
defaultFmTag | Default tag for posts | Others |
defaultFmCategory | Default category for posts | "" |
defaultFmToc | Enable table of contents by default | false |
defaultFmComments | Enable comments by default | false |
defaultFmMath | Enable math equations by default | false |
transitions | Enable view transitions | true |
ogFontPath | Path to a local font file for OG images, bypassing the Astro Fonts API | fonts/NotoSansTC-Regular.ttf |
postMdUrl | Generate a Markdown version of your blog posts for LLMs to crawl | true |
llmsTxt | Generate llms.txt for LLMs to crawl your blog posts (need postMdUrl to be true) | false |
viewAsMD | Add a “View as Markdown” button to post (need postMdUrl to be true) | true |
disqusShortname | Disqus shortname | your-disqus-shortname |
giscusRepo | Giscus repository | user/repo |
giscusRepoId | Giscus repository ID | |
giscusCategory | Giscus category name | |
giscusCategoryId | Giscus category ID |
*: important
lang.ts
Internationalization (i18n) language and locale settings.
Key settings:
lang: BCP 47 language tag (e.g.,en,zh-TW)langOg: Open Graph locale tag (e.g.,en_US,zh_TW)timeZone: IANA time zone (e.g.,America/New_York,Asia/Taipei)
To add a new language, modify the myLang object following the en template and update the exported _t constant.
socials.ts
Social media links displayed in the site footer.
Each social link object contains:
title: Link display texthref: URL to the social profile
Example:
{ title: "My GitHub", href: "https://github.com/username",}astro.config.ts
Astro config, please refer to Configuration overview and Configuration Reference.
Features
Details of each feature.
Auto-generate Description
If there is no description in the frontmatter, one will be generated automatically. There are two ways this is done:
- If there is a
<!-- more -->tag, the description will be the content from the first line up to the<!-- more -->tag. - If there is no
<!-- more -->tag, the firstgetDescriptionCountcharacters will be used.
For performance reasons, only the first getDescriptionMaxLines lines of each .md file will be processed.
You can adjust getDescriptionCount and getDescriptionMaxLines in site.ts.
Fonts
By default, Astro Jing downloads Geist (body) and Fira Mono (code) at build time via Astro’s built-in font API.
If you prefer system-native fonts — for example, to use Traditional Chinese fonts like PingFang TC / Microsoft JhengHei without any web font download — you can switch manually:
astro.config.ts— Remove the--font-bodyand--font-monoentries from thefontsarray. Keep--font-og(Satori needs it to generate OG images).fonts: [// Remove --font-body and --font-mono entries{cssVariable: "--font-og",name: "Noto Sans",weights: [400],styles: ["normal"],formats: ["woff"],provider: fontProviders.fontsource(),},],src/layouts/BaseLayout.astro— Replace the two<Font>tags with an inline style that defines the CSS variables directly:<!-- Replace: --><Font cssVariable="--font-body" preload /><Font cssVariable="--font-mono" /><!-- With: --><style is:inline>:root {--font-body:"PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system,BlinkMacSystemFont, "Segoe UI", sans-serif;--font-mono:ui-monospace, "Cascadia Code", Menlo, Monaco, Consolas, "Courier New", monospace;}</style>
Use
is:inlineso Astro does not scope the<style>tag — scoped styles would prevent:rootfrom applying globally.
All other CSS files (global.css, post.css, etc.) already use var(--font-body) and var(--font-mono) and require no changes.
OG image font
OG images are rendered by Satori, which relies solely on the --font-og font’s glyphs — it does not fall back to system fonts. By default --font-og is fetched via the Astro Fonts API, whose default subset only covers Latin characters. If your post titles/tags contain non-Latin characters (e.g. Chinese, Japanese, and Korean) that aren’t in that subset, they will render as missing-glyph boxes in OG images.
To fix this, set ogFontPath in site.ts to the path (relative to the project root) of a local font file that covers the characters you need, e.g.:
ogFontPath: "fonts/NotoSansTC-Regular.ttf",When ogFontPath is non-empty, that font file is read directly for OG image rendering, bypassing the Astro Fonts API and its subsetting entirely. Leave it as "" to keep using the Astro Fonts API.
Syntax highlighting
Astro Jing uses Expressive Code for syntax highlighting.
You can adjust its config in astro.config.ts. Themes
Example:
export default defineConfig({ // ... integrations: [ expressiveCode({ plugins: [pluginLineNumbers()], themes: ["catppuccin-latte", "one-dark-pro"], defaultProps: { wrap: false, showLineNumbers: false, }, }), // ... ],});Deploy
You can easily deploy Astro Jing to a variety of platforms, including GitHub Pages, Netlify, Cloudflare, Vercel, and more, please refer to Deploy your Astro Site.