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
- Get a cloudflare account
- Connect a domain to your cloudflare account (optional)
Quickstart
npm create cloudflare@latest -- wiki --framework=astro- Select the docs (Starlight) theme and Go grab a glass of water while waiting for npm to finish
- 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-checkimport { defineConfig } from 'astro/config';import starlight from '@astrojs/starlight';
// https://astro.build/configexport default defineConfig({ site: 'https://wiki.advik.one', integrations: [ starlight({ title: 'Everything I Know', social: { github: 'https://github.com/ADV1K/', twitter: 'https://x.com/ThisIsAdvik' }, }), ],});- Update the wiki homepage at
src/content/docs/index.md
---title: My Knowledge Wiki 🌿sidebar: hidden: true---
Everthing I Know and some more- Add your markdown files to
src/content/docsand assets tosrc/assets - 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 configdist: Wiki htmlsrc/assets/: Images, Music, Videos, etc.src/content/docs: Your markdown noteswrangler.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 && makeThe 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:
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!