Astro博客

margin — Astro 博客模板

作者 Liteink

Margin 是一款基于 Astro 的深色编辑风格博客主题,面向杂志、期刊与独立出版场景,内置全文搜索、目录、作者页与分类归档。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-02查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

亮/暗模式,跟随系统并支持手动切换,偏好保存在 localStorage

02

基于 Pagefind 的零服务端全文搜索,搜索脚本仅在搜索页加载

03

文章页自动生成目录并带滚动监听

04

使用 Astro 内容集合管理 Markdown/MDX,分类、作者页与 RSS 由 frontmatter 自动生成

05

内置社交分享、RSS、站点地图、代码高亮及 Open Graph、Twitter Cards、JSON-LD 等 SEO 输出

06

站点配置集中在 src/config.json,可调整导航、作者开关、社交与分享链接

模板详细介绍

Margin 是一款以高对比度编辑排版为特征的 Astro 博客主题,定位是杂志、期刊和独立出版类内容站点。它使用 Astro 的内容集合管理 Markdown/MDX 文章,分类、作者页和 RSS 会依据 frontmatter 自动生成。主题提供亮/暗两种模式,可通过手动开关切换并借助 localStorage 记住选择。

功能层面,Margin 集成 Pagefind 实现零服务端全文搜索,文章页自动生成目录并带滚动监听;同时包含社交分享按钮、RSS、站点地图、代码高亮,以及 Open Graph、Twitter Cards、JSON-LD 等 SEO 相关输出。默认不加载 JavaScript,Pagefind 脚本仅在搜索页引入。

站点配置集中在 src/config.json,可设置站点标题、描述、导航、作者开关、社交链接、分享链接和页脚。文章写在 src/content/posts/ 下,支持 Markdown 与 MDX。构建命令会先执行 Astro 构建,再由 Pagefind 建立索引,产物为静态 dist/ 目录,可部署到任意静态托管。

限制方面,README 提到联系表单需接入 Formspree 或类似服务,真实提交要自行配置端点,其额度与费用需单独核对。演示中的图片、字体、图标等第三方素材需按各自许可判断,不能仅凭代码的 MIT 许可视为可自由使用。域名、托管等外部服务也可能产生费用。

Astro博客

适合你的项目吗?

适用场景

  • 搭建杂志、期刊或独立出版类内容站点
  • 为写作者建立以文章阅读为核心的博客,需要目录与全文搜索
  • 需要按分类和作者组织文章,并自动生成归档页
  • 部署到 Cloudflare Pages、Netlify、Vercel 或 GitHub Pages 等静态托管

适合人群

  • 习惯用 Markdown/MDX 写作并希望用 Astro 管理内容的个人或团队
  • 需要亮暗模式、全文搜索和 SEO 基础输出的博客项目
  • 以编辑排版和长文阅读为主的出版物站点
  • 希望将静态产物部署到任意静态托管、不依赖服务端搜索的站点

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    克隆仓库后执行 npm install,再用 npm run dev 在本地预览

  2. 2

    站点标题、描述、导航、作者开关、社交与分享链接等配置在 src/config.json 中修改

  3. 3

    文章放在 src/content/posts/,frontmatter 支持 title、description、pubDate、author、category、featured、image 等字段

  4. 4

    构建使用 npm run build,会先执行 Astro 构建再由 Pagefind 建立索引,部署 dist/ 目录

  5. 5

    联系表单需自行接入 Formspree 或类似服务并配置端点,其额度与费用需单独核对

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 联系表单为静态页面,需自行接入 Formspree 或类似第三方服务并配置提交端点;该服务的可用额度、隐私条款与费用需单独核对,不属于主题自带功能。
  • 部署需自备静态托管服务(如 Cloudflare Pages、Netlify、Vercel、GitHub Pages),域名与托管可能产生费用,需自行确认。
  • 演示所用字体、图片、图标等第三方素材的许可需按各自来源单独核实,不能仅凭代码的 MIT 许可视为可自由使用。
  • README 提及 Formspree 表单服务;真实提交需配置服务端点,其使用额度与费用需单独核对。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

Contact form (connect to Formspree or similar)

README 原文

Deploy the `dist/` folder to any static host

README 原文

[Fraunces](https://fonts.google.com/specimen/Fraunces)

README 原文
https://github.com/Liteink/margin/blob/main/LICENSEhttps://github.com/Liteink/margin/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 80 / 100
技术栈
Astro
网站类型
博客
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-08-11
截图检查日期
2026-10-02

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Astro。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。

查看当时使用的来源资料

SHA-256: 48e08d8a643720b71687fd061e598efabd43539e2f7e084027f9e3e914548bd0

2026-10-02T06:41:21.576Z

来源文件 / 仓库
# Margin — A Dark Editorial Astro Theme

A high-contrast editorial theme for magazines, journals, and independent publications. Built for writers who want their words to do the talking.

[Live Demo](https://astro-uzen-theme.pages.dev) · [License: MIT](./LICENSE)

![Margin Theme](https://astro-uzen-theme.pages.dev/og.png)

## Features

- **Light & Dark Mode** — System-aware with manual toggle, persisted via localStorage
- **Full-Text Search** — Powered by [Pagefind](https://pagefind.app), zero server required
- **Table of Contents** — Auto-generated with scroll spy on every post
- **Content Collections** — Write posts in Markdown, manage with Astro's built-in content layer
- **Author Profiles** — Dedicated author pages with post listings
- **Category Archives** — Organized by category with clean grid layouts
- **Social Sharing** — Built-in share buttons for Twitter/X, Facebook
- **RSS Feed** — Auto-generated at `/rss.xml`
- **Sitemap** — Auto-generated, includes all pages
- **Syntax Highlighting** — Styled code blocks for technical writing
- **SEO Ready** — Open Graph, Twitter Cards, JSON-LD structured data, canonical URLs
- **Zero JS by Default** — Astro ships pure static HTML. Pagefind JS loads only on the search page
- **Responsive** — Hand-tuned breakpoints for mobile, tablet, and desktop
- **Accessible** — Semantic HTML, keyboard navigation, ARIA labels, visible focus states

## Tech Stack

| Tool | Purpose |
|---|---|
| [Astro 7](https://astro.build) | Static site generator |
| [Tailwind CSS 3](https://tailwindcss.com) | Utility-first styling |
| [Pagefind](https://pagefind.app) | Static site search |
| [Fraunces](https://fonts.google.com/specimen/Fraunces) | Display serif |
| [Inter](https://fonts.google.com/specimen/Inter) | Body sans-serif |
| [JetBrains Mono](https://fonts.google.com/specimen/JetBrains+Mono) | Code & metadata |

## Quick Start

```bash
git clone https://github.com/Liteink/margin.git
cd margin
npm install
npm run dev
```

Visit `http://localhost:4321` to see your site.

## Configuration

All site settings live in `src/config.json`:

```json
{
  "siteTitle": "Margin",
  "siteDescription": "Your site description",
  "navigation": [
    { "label": "Home", "href": "/" },
    { "label": "Technology", "href": "/category/technology" }
  ],
  "enableAuthor": true,
  "socialLinks": [...],
  "shareLinks": [...],
  "footer": { ... }
}
```

## Writing Posts

Create Markdown files in `src/content/posts/`:

```yaml
---
title: "Your Post Title"
description: "A one-line summary for SEO and social cards."
pubDate: 2026-01-15
author: "Author Name"
category: "Design"
featured: false
image:
  url: "/images/cover.jpg"
  alt: "Description of the cover image"
---

Your content here. Markdown and MDX are both supported.
```

Categories, author pages, and RSS feeds are generated automatically from frontmatter.

## Design System

| Token | Dark | Light |
|---|---|---|
| Background | `#0e0a0c` | `#faf8f6` |
| Surface | `#131012` | `#f0ede8` |
| Ink (headlines) | `#f5f0ea` | `#1a1115` |
| Body text | `#9a9088` | `#524c4a` |
| Accent | `#d4324a` | `#d4324a` |

Colors are defined as CSS custom properties in `Layout.astro`. Change them once, and the entire theme updates.

## Deployment

Build the site with search indexing:

```bash
npm run build
```

This runs Astro build, then Pagefind indexes the output. Deploy the `dist/` folder to any static host:

- **Cloudflare Pages** — Connect repo, set build command to `npm run build`
- **Netlify** — Same as above
- **Vercel** — Same as above
- **GitHub Pages** — Use the `dist/` folder as the publish directory

## Pages

- **Home** — Featured story + article grid + editor's picks + newsletter CTA
- **Post** — Full article with cover image, TOC sidebar, share buttons, related stories
- **Category** — `/category/[name]` — Posts filtered by category
- **Author** — `/author/[name]` — Posts by a specific author
- **Search** — `/search` — Full-text search powered by Pagefind
- **Subscribe** — Newsletter signup page
- **Contact** — Contact form (connect to Formspree or similar)
- **Privacy / Terms** — Legal pages via Markdown content collection
- **404** — Custom not-found page

## License

**MIT** — Free for personal and commercial use. No attribution required.

---

Built by [LiteInk](https://github.com/Liteink)
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。