sync-siyuan — Sync SiYuan Note to Hexo Blog
Sync and publish SiYuan Note documents to Hexo Butterfly blog, including content conversion and image copying.
Pre-check
- SiYuan MCP is available:
mcp__siyuan-mcp__unified_search
can be called normally
- Blog directory exists: is accessible
- Image directory exists: is accessible
- SiYuan data directory is accessible:
D:/299792458/Q7h2q9/data/assets/
If the above conditions are not met: Prompt the user to check whether SiYuan is running, MCP is configured, and the path is correct.
Usage
/sync-siyuan <document title>
Parameter:
— SiYuan document title (fuzzy matching supported)
Key Paths
| Purpose | Path |
|---|
| SiYuan assets | D:/299792458/Q7h2q9/data/assets/
|
| Blog post directory | D:/299792458/blog/butterfly/source/_posts/
|
| Blog image directory | D:/299792458/blog/butterfly/source/post_imgs/
|
Workflow
1. Search for SiYuan Documents
Use
mcp__siyuan-mcp__unified_search
:
No results → Inform the user that no matching document is found, end the process.
Multiple results → List all results for the user to select.
2. Read Document Content
Use
mcp__siyuan-mcp__get_document_content
to read the complete Markdown content.
3. Process Content
Execute in order:
- Remove the first-level heading () — Hexo uses frontmatter title
- Remove SiYuan frontmatter (if any)
- Clean up zero-width characters: , , ,
- Extract all image references, collect the list of image filenames (used in step 4)
- Replace image path: →
Image reference format example:
- Original SiYuan format:

- Converted format:

4. Copy Images
For each image filename collected in step 3:
bash
cp "D:/299792458/Q7h2q9/data/assets/<filename>" "D:/299792458/blog/butterfly/source/post_imgs/<filename>"
- Check if the source file exists before copying, warn the user if it does not exist (do not interrupt the process)
- Skip if the target file already exists (to avoid duplicate copying)
- Batch copy, process multiple files with one command
5. Check for Existing Article in Blog
Search for .md files with the same or related names under
.
6. Generate/Update Blog Article
New Article
Generate frontmatter:
yaml
---
title: <document title>
cover:
categories:
tags:
date: <current time YYYY-MM-DD HH:mm:ss>
lastmod: <SiYuan document update time>
---
Write to
source/_posts/<document title>.md
.
Remind the user to fill in cover, categories and tags.
Update Existing Article
- Keep the original frontmatter (title, cover, categories, tags, abbrlink, date)
- Only update lastmod
- Replace the body content
- Copy newly added images as well
7. Deploy (Optional)
Ask the user whether to deploy immediately. If yes:
bash
cd D:/299792458/blog/butterfly && hexo clean && hexo g && hexo d
Note: Deployment will push to GitHub Pages, execute only after confirming the user's intention.
8. Complete
Briefly inform the user of:
- Created/Updated status
- File path
- Number of copied images (list missing images if any)
Error Handling
| Symptom | Cause | Fix |
|---|
| MCP tool call failed | SiYuan is not running or MCP is not configured | Start SiYuan Note, check MCP configuration |
| Image source file does not exist | Deleted in SiYuan or filename changed | Warn the user, continue processing other images |
| Frontmatter parsing exception | Non-standard document format | Manually check SiYuan document format |
| failed | Git authentication or network issue | User manually executes |
Notes
- SiYuan image filename format:
image-YYYYMMDDHHmmss-random ID.png
- Do not modify any files under (submodule)
- abbrlink is automatically generated by the hexo-abbrlink plugin, no need to fill in manually for new articles
- It is recommended to run for local preview and confirmation before deployment