我如何使用Obsidian、Hugo、GitHub和Cloudflare进行博客写作——零成本,完全自有
How I blog with Obsidian, Hugo, GitHub, and Cloudflare

原始链接: https://ingau.me/blog/how-i-write-my-blogs-in-obsidian-and-publish-instantly/

本方案详细介绍了一个强大、免费且跨平台的博客工作流程,它利用Obsidian、Hugo、GitHub和Cloudflare Pages。 Obsidian,凭借其本地优先的纯文本方法和Minimal之类的主题,充当写作环境。笔记存储在本地iCloud、Dropbox或Google Drive文件夹中,以便在设备间无缝同步。此文件夹也用作Hugo项目的content目录。 Hugo,配合Bear Blog主题,生成静态网站。关键在于将Obsidian直接链接到Hugo的content文件夹。 GitHub实现版本控制和托管,而Cloudflare Pages提供由Git推送触发的快速自动部署。 要发布文章,只需在Obsidian中将文章前文的“draft”标志设置为“false”,提交更改并将其推送到GitHub。Cloudflare Pages会自动检测更新并重新部署网站。 此方案提供了对内容的完全控制,消除了订阅费用,并确保了长期的可移植性。虽然初始设置需要一定的技术基础,但最终结果是一个简化且可持续的博客体验。

Hacker News 的讨论围绕一篇博文展开,该博文详细介绍了如何使用 Obsidian、Hugo、GitHub 和 Cloudflare 建立一个“零成本,完全拥有”的博客系统。核心争论在于“完全拥有”的含义,许多用户认为依赖云服务与真正的所有权相矛盾。 博主 ingav 解释说,“完全拥有”指的是控制和可移植性,而不是基础设施的所有权。内容存储在本地,使用 Git 版本控制,并使用开放工具构建,方便迁移。这与锁定在特定 CMS 平台形成了对比。 用户讨论了 Jekyll 和 VSCode 等替代方案,称赞 Hugo 的速度和灵活性。一些人对 Cloudflare 可能的商业限制(相比 GitHub Pages)表示担忧。另一些人质疑静态网站生成器的必要性,更倾向于直接编写 HTML。还讨论了自定义域名集成和管理元数据等实际问题。总体而言,大家普遍赞赏这种方案提供的可移植性和控制能力。
相关文章

原文

I’ve been using Obsidian for all my writing lately, and it’s been a game changer. The local-first model means everything lives as plain text on my machine, and with the Minimal theme, the interface stays clean and distraction-free.

My vault lives in iCloud (Dropbox or Google Drive work too), so notes sync seamlessly across devices - I often start drafts on my phone and finish them later on my laptop.

For publishing, I use Hugo with the Bear Blog theme (fast, minimal), and deploy via GitHub and Cloudflare Pages. This stack gives me full control: no subscriptions, no vendor lock-in, and no risk of platforms disappearing or changing policies.

If you:

  • Use (or want to try) Obsidian
  • Don’t mind a bit of technical setup
  • Prefer writing in plain text with Git-based version control
  • Want a fast, cost-free, portable publishing flow

Then this setup might be exactly what you’re looking for. Once set up, publishing is as simple as toggling a draft flag and pushing to GitHub.

Screenshot of my Obsidian vault

Setting Up Your System

This post is a high-level outline of how it all fits together. It’s not a tutorial, but if you’re familiar with basic dev tools, it should be easy to follow. And if anything’s unclear, LLMs like ChatGPT or Claude are great for filling in the gaps.

1. Install and Set Up Hugo

First, you’ll need to install Hugo on your machine. Once installed, create a new site:

hugo new site myblog
cd myblog

Then add the Bear Blog theme (or your preferred theme):

git init
git submodule add https://github.com/janraasch/hugo-bearblog.git themes/hugo-bearblog

Update your config.toml file to use the theme. See the Bear Blog theme documentation for configuration options.

2. Connect Obsidian to Hugo

This is the key part. Hugo has a specific folder structure, and you want to write your posts in the content folder. Inside that folder, I created a blog subfolder for all my posts.

So my folder structure looks like this:

myblog/
  ├── content/
  │   ├── blog/   <- This is where I write my posts
  │   └── ...
  └── ...

To set up Obsidian:

  1. Open Obsidian
  2. Click “Open folder as vault”
  3. Navigate to your Hugo site’s blog folder (myblog/content/blog)
  4. Select this folder

This way, everything you write in Obsidian goes directly into the right folder for Hugo to process.

3. Set Up Front Matter Template

In Obsidian, make sure that your posts includes the necessary Hugo front matter:

+++
title= "Your Post Title"
date= YYYY-MM-DD
tags= ["post"]
draft= true
+++

The draft: true tag is crucial - this is what you’ll toggle to false when you’re ready to publish.

4. Preview Posts Locally

While writing, I use Hugo’s local server with draft visibility:

hugo server -D

This lets me see how everything looks in-browser before pushing live.

5. Connect to GitHub

Create a new GitHub repository for your blog, then connect your local Hugo site:

git remote add origin https://github.com/yourusername/yourblog.git
git add .
git commit -m "Initial commit"
git push -u origin main

There are plenty of GitHub tutorials if you need help with this step.

6. Set Up Cloudflare Pages

  1. Sign up for a Cloudflare account if you don’t have one
  2. Go to the Pages section and create a new project
  3. Connect to your GitHub account and select your blog repository
  4. For build settings:
    • Build command: hugo --minify
    • Build output directory: public

Cloudflare’s own documentation covers this process well.

The Publishing Workflow

Once everything is set up, publishing is simple:

  1. Write your post in Obsidian
  2. When ready to publish, change draft: true to draft: false in the front matter
  3. Commit and push to GitHub:
git add .
git commit -m "Publish new post"
git push

Cloudflare Pages will automatically detect the change and rebuild your site, typically within a minute or two.

Final Thoughts

This setup takes a bit of initial work, but the payoff is enormous. Once it’s all set up, this workflow fades into the background - I just write, commit, and publish. No friction, no fees, and everything stays in my hands. If you’re looking for a lightweight, sustainable way to blog, this might be worth trying.

联系我们 contact @ memedata.com