一个基于 Go + 文件系统的轻量静态博客,支持发布到 GitHub Pages。
演示地址:https://wofiporia.github.io/folio/
main:模板分支(不自动发布)blog:内容分支(自动发布到 GitHub Pages)
推荐流程:使用 Use this template 创建仓库,然后在 blog 分支写作并发布。
- 使用模板创建你的仓库。
- 新建并切换到
blog分支。 - 在仓库
Settings -> Pages中把Source设为GitHub Actions。 - 在
Settings -> Environments -> github-pages里允许blog分支部署。 - push 到
blog,等待 Actions 完成。
示例:
主要字段:
site_title:站点名。site_description:站点描述(首页与默认 SEO 描述)。site_url:站点完整 URL(用于 canonical / og:url)。author_name:文章未写作者时的默认作者名。author_github:作者 GitHub 地址(支持直接写用户名,程序会自动补全为https://github.com/<name>)。theme:主题名(对应themes/<theme>)。default_description:缺省 SEO 描述。default_og_image:缺省 OG 图片 URL。default_og_type:缺省 OG 类型。
评论字段:
comments_provider:utterances或giscus。- 若配置不完整,评论区会自动关闭,不影响页面渲染。
当前内置主题:
default:简约风。kinetic:更大胆的视觉与排版。
主题目录约定:
themes/
└── <theme>/
├── templates/
│ ├── index.html
│ ├── post.html
│ ├── tags.html
│ ├── archives.html
│ ├── search.html
│ ├── 404.html
│ └── partials/
│ ├── head-common.html
│ └── nav.html
└── static/
├── style.css
└── favicon.png
说明:模板和静态资源都支持自动回退到 themes/default。
文章放在 posts/*.md,使用 Front Matter:
---
title: "我的第一篇文章"
author: "Your Name"
date: "2026-03-03T10:00:00Z"
tags: ["博客", "Go"]
draft: false
---author可选;不填时回退到config.json的author_name。draft: true的文章不会出现在前台。
- 首页:
/ - 文章页:
/post/{slug} - 标签页:
/tags - 归档页:
/archives - 搜索页:
/search(前端读取search-index.json) - SEO:
description、Open Graph、canonical、article:published_time
启动本地服务:
go run .访问:http://localhost:8080
导出静态站点:
go run ./cmd/build -out dist -base-path /your-repo-name可选参数:
-config:指定配置文件路径(默认config.json)-site-url:导出时覆盖站点 URL
可在仓库变量中设置 PAGES_BASE_PATH(Settings -> Secrets and variables -> Actions -> Variables)。
常见值:
- 项目页:
/your-repo-name - 用户主页根路径:
/ - 自定义子路径:
/blog
优先级:
PAGES_BASE_PATH- 自动回退
/<repo-name>
folio/
├── main.go
├── cmd/build/main.go
├── config.json
├── posts/
├── themes/
├── .github/workflows/pages.yml
└── README.md
{ "site_title": "Folio", "site_description": "一个基于 Go 和文件系统的轻量博客。", "site_url": "https://your-name.github.io/your-repo", "author_name": "Your Name", "author_github": "your-github-id", "theme": "default", "default_description": "这里什么都没有写。", "default_og_image": "", "default_og_type": "website", "comments_provider": "utterances", "comments_repo": "owner/repo", "comments_issue_term": "pathname", "comments_label": "comment", "comments_theme": "github-light" }