Introduction
If you’re looking for a lightweight, version-controlled, and customizable way to document your APIs, Obsidian + Hugo is a killer combo.
My Favorite actually.. :)
You can write everything in Markdown, generate a fast static site, and self-host your API documentation.
Side Note: Whats also nice about Obsidian, is since everything is in markdown, you can switch between Obsidian and Visual Studio code (for example), very easily..
1️⃣ Setting Up Hugo
Install Hugo
First, install Hugo based on your OS:
Mac (Homebrew):
|
|
Windows (Chocolatey):
|
|
Linux:
|
|
Verify the installation:
|
|
You should see an output like:
|
|
Create a New Hugo Site
|
|
2️⃣ Choosing an OpenAPI-Compatible Hugo Theme
Hugo doesn’t natively support OpenAPI, but you can use a theme that does!
Recommended OpenAPI Hugo Themes
Theme | Link |
---|---|
Docsy | https://github.com/google/docsy |
Learn | https://github.com/matcornic/hugo-theme-learn |
DocuAPI | https://github.com/bep/docuapi |
Install a Theme
For this guide, we’ll use DocuAPI:
|
|
3️⃣ Writing OpenAPI Documentation in Obsidian
Organizing Your Files
In Obsidian, structure your API docs like this:
|
|
Example: Introduction.md
|
|
4️⃣ Rendering OpenAPI Specs in Hugo
To display OpenAPI specs, you need Redoc or Swagger UI.
Using Redoc (Recommended)
1️⃣ Download Redoc JavaScript
|
|
2️⃣ Create a Page for OpenAPI Docs
Create content/api/openapi.md
and add this:
|
|
3️⃣ Add Your OpenAPI Spec
Place your openapi.yaml
file in static/
:
|
|
5️⃣ Running Hugo Locally
Start the Hugo development server:
|
|
Visit: http://localhost:1313 🎉
6️⃣ Deploying Your OpenAPI Docs
GitHub Pages Deployment
1️⃣ Build the static site:
|
|
2️⃣ Push to GitHub:
|
|
3️⃣ Deploy with GitHub Actions
Create .github/workflows/hugo.yml
:
|
|
✅ Your site is live on https://YOUR_USERNAME.github.io/openapi-docs/
Alternative Hosting
Service | Link |
---|---|
Netlify | https://www.netlify.com |
Vercel | https://vercel.com |
Cloudflare Pages | https://pages.cloudflare.com |