# Using Joplin to publish a wiki

URL: https://joaocosta.dev/blog/14
Published: 2024-12-05 · 3 min read

Recently I've been on an adventure to find a note-taking app that allows me to publish my notes as a personal wiki. I've ended up choosing Joplin.

You can access the wiki [here](https://wiki.joaocosta.dev).

## Why Joplin as a wiki software

For a few years now, I've published a personal wiki. This basically means sharing a part of my personal notes that I decided to make public. I used to use dedicated wiki software. Started with [DokuWiki](https://www.dokuwiki.org/dokuwiki), then moved to [Wiki.js](https://js.wiki/). The problem was that reaching out to the wiki to take notes broke my workflow, so I didn't write much. At the same time, I was trying to settle on a single note taking software. This is where [Joplin](https://joplinapp.org/) comes in.

Joplin fits my use cases nicely:

- It's open source.
- Allows me to take notes in Markdown format.
- Has self-hosted sync options (bonus by being builtin).
- Allows me to have a shared notebook with my partner.
- Allows me to publish notes aka my personal wiki (using [Joplin Server](https://github.com/laurent22/joplin/blob/dev/packages/server/README.md)).

## How I did it

Joplin allows me to publish individual notes (make them publicly viewable), but I wanted to publish an entire directory/notebook (my wiki). For this reason I went with a slightly different approach. I'm using a Github action to fetch my Wiki notebook through the [joplin cli](https://joplinapp.org/help/apps/terminal/) and export the contents as markdown files. There is another action that takes these markdown files and builds the Wiki using [mdBook](https://rust-lang.github.io/mdBook/).

In other words:

- I write in my notetaking app (Joplin) inside a Wiki notebook (directory).
- Github fetches these notes and exports them as markdown files.
- An intermediate step builds the Wiki summary (a sitemap needed by mdBook).
- Lastly, Github builds and publishes the Wiki with Github pages.

This happens once a day at midnight (UTC). The contents of the [repo](https://github.com/joaocostaifg/wiki) are something like a daily snapshot of the Wiki notebook.

## Hosting Joplin server

I host Joplin server using Docker compose:

```yml
services:
  joplin:
    image: joplin/server:latest
    container_name: joplin
    ports:
      - "22300:22300"
    environment:
      - APP_BASE_URL=https://joplin.myserver.com
      - APP_PORT=22300
      - SQLITE_DATABASE=/data/db.sqlite
    volumes:
      - joplin_data:/data
    restart: unless-stopped

volumes:
  joplin_data:
```

This runs the server on port 22300 using an SQLite database. Unless you have lots of users, I see no reason to use the PostgreSQL database option.

## Want to the same as well?

- Fork the [repo](https://github.com/joaocostaifg/wiki).
- Set the following Github secrets (for the action):
  - `JOPLIN_PATH` - your Joplin server instance URL. Something like `https://joplin.myserver.com`
  - `JOPLIN_USER` - the Joplin user that is gonna be used to fetch the contents. I created a user for this with whom I share the Wiki notebook.
  - `JOPLIN_PASSWORD` - the password for the Joplin user.

The step that builds the mdBook is on a [separate action](./.github/workflows/mdbook.yml). If you want to build another kind of site, for example a personal blog, you can change this action to build something else. There's a bunch of Github actions already setup for that.

## Conclusion

[Joplin](https://joplinapp.org/) and [mdBook](https://github.com/joaocostaifg/wiki) are pretty cool. Finally, I can write my notes in a single place and easily keep them synced between my devices. I highly recommend giving [Joplin](https://joplinapp.org/) a try.

Stay safe :P
