Zenn: GitHub Push/PR Publishing
Overview
Zenn publishes by syncing a GitHub repository. Articles/books are Markdown files placed in specific directories, and Zenn CLI helps you preview and scaffold content locally.
This skill defines an operational workflow that is both fast and safe:
- - Draft in PRs (
published: false) - Review with local preview (
zenn preview) - Publish by flipping
published: true once the PR is ready
Inputs to collect
- - Repo path (local clone) and GitHub remote
- Publishing branch (the branch connected to Zenn)
- Article metadata: title, emoji, type (
tech or idea), topics, published - Slug / filename for the Markdown file (kebab-case recommended)
- Assets (images) location strategy (recommended:
images/<slug>/...)
File placement rules (Zenn)
- - Articles must be placed under
articles/ as individual .md files. - (Optional) Books are placed under
books/.
Recommended repo layout:
CODEBLOCK0
Zenn CLI usage (local)
Install / init (one-time per repo)
If Zenn CLI is not set up yet in the repo:
CODEBLOCK1
Preview locally
CODEBLOCK2
Create new content
CODEBLOCK3
List existing content
CODEBLOCK4
Article template (copy/paste)
Create
articles/<slug>.md:
CODEBLOCK5
Notes:
- - Title is in front matter, so body headings should generally start at
##. - Keep topics to a small, consistent set for series-building.
Standard workflow (recommended)
1) Draft in a feature branch
- 1. Create or edit
articles/<slug>.md (keep published: false) - Add images (if any) under INLINECODE13
- Preview locally:
CODEBLOCK6
2) Open a PR
git checkout -b article/<slug>
git add articles/<slug>.md images/<slug>/
git commit -m "Add draft: <title>"
git push -u origin article/<slug>
Open a PR into the Zenn publishing branch.
3) Publish safely
Option A (safest): publish in a second tiny PR/commit
- 1. Merge the draft PR (still
published: false) - Flip to
published: true and merge a small PR
Option B (fast): publish in the same PR
- - Keep
published: false during writing/review - Flip to
true right before merging
Quality gate checklist (minimum)
Before setting
published: true, verify:
- - No confidential info (customer names, internal URLs, unreleased metrics)
- Code blocks are runnable or clearly labeled as pseudo-code
- Images render and paths are correct
- Links are correct
- Spelling / headings / formatting are acceptable
Troubleshooting
- - Preview differs from Zenn web or CLI shows update notice:
npm install zenn-cli@latest
- Ensure they are committed and pushed
- Ensure references look like
/images/<slug>/... (not
./images/...)
- File is under
articles/
-
published: true
- The branch synced to Zenn is the one being updated
When does this not work?
- - Skipping PR review (direct publish) increases risk of accidental leaks.
- Relying on UI/browser automation instead of GitHub sync is brittle to UI changes.
- Mixing multiple articles in one file or placing files outside
articles/ will not publish as expected.
Zenn: GitHub推送/PR发布
概述
Zenn通过同步GitHub仓库进行发布。文章/书籍是放置在特定目录下的Markdown文件,Zenn CLI可帮助你在本地预览和搭建内容。
本技能定义了一个既快速又安全的操作流程:
- - 在PR中起草(published: false)
- 通过本地预览进行审阅(zenn preview)
- PR准备就绪后,将published改为true即可发布
需要收集的输入
- - 仓库路径(本地克隆)和GitHub远程仓库
- 发布分支(与Zenn连接的分支)
- 文章元数据:标题、表情符号、类型(tech或idea)、主题、发布状态
- Markdown文件的别名/文件名(建议使用短横线命名法)
- 资源文件(图片)存放策略(建议:images//...)
文件放置规则(Zenn)
- - 文章必须作为单独的.md文件放置在articles/目录下。
- (可选)书籍放置在books/目录下。
推荐的仓库结构:
.
├─ articles/
│ └─ 20260216-openclaw-to-zenn.md
├─ books/ # 可选
└─ images/ # 可选,推荐使用
└─ openclaw-to-zenn/
├─ cover.png
└─ diagram.png
Zenn CLI使用(本地)
安装/初始化(每个仓库只需一次)
如果仓库中尚未设置Zenn CLI:
bash
npm init --yes
npm install zenn-cli
npx zenn init
本地预览
bash
npx zenn preview
创建新内容
bash
npx zenn new:article
npx zenn new:book
列出已有内容
bash
npx zenn list:articles
npx zenn list:books
文章模板(复制使用)
创建articles/
.md:
md
title: 記事タイトル
emoji: 🧩
type: tech # tech 或 idea
topics: [ruby, rails, ai]
published: false
TL;DR
背景
...
实现/验证
...
收获
...
参考
注意:
- - 标题在front matter中,因此正文标题通常应从##开始。
- 保持主题数量少且一致,便于构建系列文章。
标准工作流程(推荐)
1) 在功能分支中起草
- 1. 创建或编辑articles/.md(保持published: false)
- 添加图片(如有)到images//...目录下
- 本地预览:
bash
npx zenn preview
2) 创建PR
bash
git checkout -b article/
git add articles/.md images//
git commit -m 添加草稿:<标题>
git push -u origin article/
向Zenn发布分支发起PR。
3) 安全发布
选项A(最安全):通过第二个小型PR/提交发布
- 1. 合并草稿PR(仍为published: false)
- 将published改为true并合并一个小型PR
选项B(快速):在同一PR中发布
- - 在编写/审阅期间保持published: false
- 在合并前立即改为true
质量检查清单(最低要求)
在设置published: true之前,请验证:
- - 无机密信息(客户名称、内部URL、未发布的指标)
- 代码块可运行或明确标注为伪代码
- 图片能正常显示且路径正确
- 链接正确
- 拼写/标题/格式可接受
故障排除
- - 预览与Zenn网页不一致或CLI显示更新通知:
bash
npm install zenn-cli@latest
- 确保已提交并推送
- 确保引用格式为/images//...(而非./images/...)
- 文件在articles/目录下
- published: true
- 同步到Zenn的分支是正在更新的分支
何时此方法不适用?
- - 跳过PR审阅(直接发布)会增加意外泄露的风险。
- 依赖UI/浏览器自动化而非GitHub同步,容易因UI变化而失效。
- 将多篇文章混在一个文件中或将文件放在articles/目录之外,将无法按预期发布。