Skip to content

How To Publish A Wiki

Do you write notes? Do you write them in markdown? Do you want to share them with the world? If you answered yes to all three questions then this guide is for you.

The easiest way to publish a wiki is to write all your content in markdown and use a Static Site Generator. I’ll be using Astro with the Starlight theme in this demonstration.

Prerequisite

  1. Get a cloudflare account
  2. Connect a domain to your cloudflare account (optional)

Quickstart

  1. Install Node.js and npm
  2. Create a new project
Terminal window
npm create cloudflare@latest -- wiki --framework=astro
  1. Select the docs (Starlight) theme and Go grab a glass of water while waiting for npm to finish
  2. Select deploy with cloudflare and use your login credentials. At the time of writing this, astro cloudflare adapter is broken and will throw an error while building the site, simply remove it from the astro.config.mjs, we don’t need it anyway.
// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
// https://astro.build/config
export default defineConfig({
site: 'https://wiki.advik.one',
integrations: [
starlight({
title: 'Everything I Know',
social: {
github: 'https://github.com/ADV1K/',
twitter: 'https://x.com/ThisIsAdvik'
},
}),
],
});
  1. Update the wiki homepage at src/content/docs/index.md
---
title: My Knowledge Wiki 🌿
sidebar:
hidden: true
---
Everthing I Know and some more
  1. Add your markdown files to src/content/docs and assets to src/assets
  2. Add a custom domain and deploy using npm run deploy

And there you have it, your own personal knowledge wiki, in 7 simple steps.

Make sure to add a title to all your notes! Add the following at the top of all your notes.

---
title: My awesome page
---

Project Structure

  • astro.config.mjs: Wiki config
  • dist: Wiki html
  • src/assets/: Images, Music, Videos, etc.
  • src/content/docs: Your markdown notes
  • wrangler.toml: Cloudflare config

Automating deployments

You could deploy either by npm run deploy or by connecting your git repo with cloudflare pages so that everytime you push, it deploys automatically.

I personally don’t like the hassle of manual deployments everytime i make a change to my wiki and prefer a more set it and forget it approach by making a cron job. Additionally, I prefer to write my notes in Obsidian instead of NeoVIM, so I have a handy Makefile for this.

deploy: copy
pnpm run deploy
dev: copy
pnpm run dev --host 0.0.0.0
copy:
rm -r ./src/content/docs/*
cp -r ~/data/notes/Wiki/* ./src/content/docs/

It copies my notes over before triggering a deployment. Symlinks don’t work here, I’ve tried.

Install cronie and enable it by running sudo systemctl enable --now cronie Edit your crontab by running crontab -e

0 * * * * cd ~/data/code/wiki && make

The above cronjob runs every hour and deploys the wiki.

Alternatives

If you don’t like astro or the starlight theme for whatever reason there are other frameworks and themes for you. Most notably:

  1. Vitepress if you like Vue
  2. Nextra if you like Next.js
  3. Docusaurus if you like React

All of these tools do have similar features, it just comes down to preference. So pick a theme that you like and start writing already!