# Emacs and Org Mode to Manage a Website
A funny story happened to me recently. I accidentally deleted my Hugo-managed website from a local drive. Not a big deal. I had a backup copy in a git repository and on a backup drive. However, I saw this as an opportunity to move my notes and posts from Apple Notes to Emacs org-mode. Although I had tried to use it before, I struggled to find an effective way to use it in my daily routine.
But this time it was different.
[Spacemacs](https://www.spacemacs.org/) is an exceptional starting point with sane defaults and all the features I need. Everything works as expected right out-of-the-box.
I whipped up a quick prototype over the weekend: Emacs generates a website from org pages and copies static assets such as css files and images.
Lastly, I decided to migrate off [Plausible](https://plausible.io/). I like this tool a lot, but my static websites have approximately 5k visits per month, and I can process .log files with a simple script. [VisiData](https://www.visidata.org/) is an amazing tool to visualize data and automatically generate pivot tables.
![[visidata-stats.png]]
Makefile handles most common operations:
- `make build`: incrementally build a website
- `make serve`: `caddy` serves website on :1313 port
- `make publish`: `rsync` a website to remote server
- `make stats`: show visits, requires `jq` and `visidata`
- `make watch`: watch files and automatically rebuild a website after they change, requires `entr`
- `make clean`: clean up
I uploaded files to a repository:
https://github.com/oneearedrabbit/emacs-website-publisher
I could have used Terraform to configure the server, but right now it is done manually:
- Cheap DigitalOcean instance, install Arch: https://wiki.archlinux.org/title/Arch_Linux_on_a_VPS
- pacman -S rsync caddy ufw
- sh -c 'curl https://raw.githubusercontent.com/caddyserver/dist/master/init/caddy.service > /etc/systemd/system/caddy.service'
- chmod 644 /etc/systemd/system/caddy.service
- ufw allow proto tcp from any to any port 80,443
- edit /etc/caddy/Caddyfile and modify root \* /srv/http/example.com
- systemctl start caddy
I long for the days when hosting my own applications gave me a greater sense of connection to the tools. It breaks my heart to see the shift and the loss of that intimate connection with the digital life. I refuse to be the consumer.
However, as much as I enjoy this journey, I feel like a part of it is missing until I can finally have my very own RPi connected to Internet running quietly in a cozy corner. One day, but not today.