Second Brain: Crafted, Curated, Connected, Compounded on 10月02日
Obsidian到Quartz的笔记发布流程
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了如何通过Obsidian Vault将笔记发布到Public Second Brain,使用开源Quartz和GoHugo实现自动化部署。从多个网站迁移历程到当前流程,包括使用#publish标签自动发布、Rust脚本优化、GitHub Actions部署选项,以及如何处理Wikilinks、图片、Admonitions等Obsidian特性。还介绍了自定义封面图、自托管和GitHub部署方案,以及笔记处理流程和配置细节。

通过#publish标签自动筛选并发布Obsidian Vault中的笔记到Quartz git-repo,使用Python或Rust脚本实现自动化流程。

采用Rust脚本替代Python脚本,大幅提升发布速度(30倍),并正确处理Hugo要求的#hashtags。

支持离线撰写笔记,通过Obsidian同步至Vault,在笔记本中运行make deploy即可自动部署到Public Second Brain。

提供自托管和GitHub Actions两种部署方案,自托管通过rsync同步public文件夹,GitHub Actions则基于commit触发部署。

支持自定义笔记封面图、描述,以及使用Obsidian的Wikilinks、图片、Admonitions和Quotes等功能,通过主题样式实现无缝迁移。

This is my documentation of how I publish my notes from a private Obsidian vault to my Public Second Brain with open-source Quartz and GoHugo.

Video Format

Part of how I publish is also on my YouTube video My Obsidian Note-Taking Workflow about my Note-Taking Workflow article.

# Journey of Publishing Notes

I had several iterations. I used to have an HTML/CSS/PHP website, moved to a traditional blog with WordPress, and now have a Static Site Generators (SSG)-blog with GoHugo and a Second Brain (where you read this note) with GoHugo/Quartz.

On this page, I elaborate on how I can simply write in my Obsidian Vault, add #publish anywhere in my note, and run make deploy and it’s published on my public brain. No conversion, no extra formatting, no nothing needed, just running a make file.

I can write offline, on my mobile phone, or wherever I want; Obsidian will sync it across. Publishing will happen on my laptop (running the make deploy, which essentially does a rsync to my web hosting).

# Publish

How do I publish? There are two steps.

    I added a Python script find-publish-notes.py to the Makefile to copy all my SecondBrain notes from my Obsidian Vault with the hashtag #publish and copy it into the Quartz git-repo.
      Since 2023-06-07: I switched to a Rust-script that does the same but adds #hashtags properly as Hugo requests, and it is 30x faster. To get the Rust executable, you need to run cargo build --release from within the utils/obsidian-quartz folder.
    I ran the make deploy that syncs the changes to my website. This command copies notes with the hashtag “publish” and deploys to brain.ssp.sh. See also more in below .
      Since I use GitHub, I could also create a GitHub Action to deploy on commit. But I actually prefer to run the make file.This make deploy also included a go-program that collects all backlinks into two JSON files assets/indices/contentIndex.json and /assets/indices/linkIndex.json. This small util used is hugo-obsidian (see Makefile) written by Jacky Zhao. Here’s the source. But it is not maintained anymore (as there is now a v4 without it) and it had bugs and didn’t show all my backlinks. That’s why I forked it and fixed the backlinks. You can find it here: sspaeti/hugo-obsidian.

Quartz v3 Workaround

I copy all my Zettels in the root folder instead of adding sub-folders in Quartz. This way I can use Wikilinks [[]] and do not need to change to absolute paths - which I do not want to activate in my Second Brain.

# Deployment

Here I describe how I deploy my second brain.

# Self Hosting

I self-host on my own server as I already have hosting for my website. The only thing I do I rsync the public-folder to my web hosting, that’s all. The script shows how I do it. The actual line is rsync -avz --delete public/ USER@DOMAIN.com:~/www/brain (just replace with your user and domain).

# GitHub

If you do want to use GitHub actions, you can check the Data Glossary (glossary.airbyte.com) which is the same setup as Quartz, but there we use GitHub. Checkout the required deploy.yaml that makes the magic work

Basically, when someone changes the branch hugo, it will deploy changes to master branch and publish that. I think I wrote some more details here.

# Added Features

# Adding an Image (Front Matter)

I added the option to overwrite the header image, and its width and height for each note, as well as the description. E.g. in the Frontmatter I can now overwrite the terms with:

123456
---ogimage: de-vault.jpgogwidth: 1024ogheight: 761ogdescription: this is my new description---

# Obsidian Integration

This Hugo site includes custom processing for two key Obsidian markdown features, allowing seamless migration of content from Obsidian to the blog.

Converts Obsidian-style wikilinks to external links pointing to your second brain.

Source: /layouts/partials/process-wikilinks.html

Example:

12
[[Default Path]][[My Note|Custom Display Text]]

Output:

12
<a href="https://ssp.sh/brain/default-path/">Default Path</a><a href="https://ssp.sh/brain/my-note/">Custom Display Text</a>

Configuration: Set brainBaseURL in your site params:

12
[languages.en.params]brainBaseURL = "https://ssp.sh/brain/"

# 2. Images

Converts Obsidian-style image links to Hugo imgproc shortcodes for automatic image processing.

Source: /layouts/partials/process-images.html

Examples:

12
![[img_Why are we here on Earth_1745240448324.webp]]![[my-screenshot.png|Alt text description]]

Output:

12
{ {< imgproc src="img_Why are we here on Earth_1745240448324.webp" caption="">}}{ {< imgproc src="my-screenshot.png" caption="Alt text description">}}

Workflow: Simply copy your images from Obsidian’s attachment folder to your Hugo post’s bundle folder, and the image references will work automatically.

# 3. Admonitions

Converts Obsidian-style admonitions to styled warning/note boxes using the theme’s admonition system.

Source: /layouts/partials/process-admonitions.html

Supported Types:

    - Note admonitions (blue styling) - Abstract/summary admonitions - Information admonitions - Tip admonitions (green styling) - Success admonitions (green styling) - Question admonitions - Warning admonitions (orange/red styling) - Failure admonitions (red styling) - Danger admonitions (red styling) - Bug admonitions - Example admonitions - Quote admonitions

Examples:

Standard format (with empty line):

123456789
>  Important Notice> > This is a warning message that will be displayed in a styled box.>  Additional Information> > This is a note with additional context.> > Multiple paragraphs are supported.

Compact format (no empty line):

12345
>  Quick tip> This content appears directly after the title without an empty line.>  Achievement unlocked> This format also works for single-line content.

Output: Styled admonition boxes matching the theme’s design system.

# 4. Quotes

Normalizes blockquote formatting by removing unnecessary <p> wrappers for consistent styling.

Source: /layouts/partials/process-quotes.html

Example:

1
> this is a quote that does not look nice rendered

Without processing:

1
<blockquote><p>this is a quote that does not look nice rendered</p></blockquote>

After processing:

1
<blockquote>this is a quote that does not look nice rendered</blockquote>

# Processing Pipeline

All Obsidian features are processed in sequence in the layout templates:

Files: /layouts/posts/single.html and /layouts/preview/single.html

12345
{{- $step1 := partial "process-images.html" (dict "Page" . "Site" .Site) -}}{{- $step2 := partial "process-wikilinks.html" (dict "content" $step1 "Page" . "Site" .Site) -}}{{- $step3 := partial "process-admonitions.html" (dict "content" $step2 "Page" . "Site" .Site) -}}{{- $processedContent := partial "process-quotes.html" (dict "content" $step3 "Page" . "Site" .Site) -}}{{- dict "Content" $processedContent "Ruby" $params.ruby "Fraction" $params.fraction | partial "function/content.html" | safeHTML -}}

Processing Order:

    Images: Convert ![[image.ext]] to Hugo imgproc shortcodes first (before wikilinks to avoid conflicts)Wikilinks: Convert [[Link]] to HTML links pointing to your second brainAdmonitions: Convert > title to styled admonition divsQuotes: Normalize regular blockquote formatting

This processing order ensures that all features work together seamlessly. You can use wikilinks within admonitions, and images are processed before wikilinks to prevent conflicts.

# Uploading Example

# Long-form example of how I publish to Quartz


Link: My Obsidian Note-Taking Workflow - YouTube

# Short Asciinema Video

# See Other Public Brains

Other Public Second Brains


Origin:
References: GoHugo Static Site Generators (SSG) Shared on SH: Hackernews, My Tech Stack
Created 2022-08-20

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Obsidian Quartz GoHugo 笔记发布 自动化部署 Wikilinks Markdown迁移
相关文章