惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
腾讯CDC
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
Y
Y Combinator Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
A
About on SuperTechFans
博客园 - 叶小钗

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker
Migrating from WordPress to Hugo
Ashish Bhatia · 2024-09-03 · via ashishb.net

Featured on Hacker News

Golang WeeklyHugo Build-Time NewsGitHub Repo stars

Why leave WordPress

For more than 10 years, this website has been running on WordPress. Over time, I come to dislike it for multiple reasons.

  1. Security: Occasionally, I got PHP shell injection and once even my credentials were compromised. The core WordPress philosophy of keeping server-side executable PHP code inside a database makes it hard to keep the overall website secure.
  2. Cost: The requirement of running a Postgres server for just a website with a few 100 (or even a few 1000) articles makes it an expensive setup.
  3. Plugins: WordPress has a great plugin ecosystem. However, they are abandoned from time to time. In 10 years, I have migrated across at least three different code syntax highlighting plugins. Upgrade and you risk plugin incompatibilities. Don’t upgrade and you risk security vulnerabilities!
  4. Co-mingling of UI and data: WordPress comingles the UI (HTML and CSS) with contents of the blog posts.
  5. No git-based flow: Git-based flow allows automation, e.g. checking broken links and auto-compressing images. One can write WordPress plugins for these but that’s some magnitude harder effort that using a CI-based automation.

Static sites

Most personal websites should be written as a static site deployed as a single docker container. This drastically reduces vendor lock-in, reduces the security attack surface, and makes the whole build process hermetic.

The stack I eventually ended up with is

  1. Markdown - all posts have to be in Markdown. Overtime, I have fallen in love with writing posts in Markdown and have been copying it over to WordPress.
  2. Single container deployment - Deployment as a single container on Google Cloud Run
  3. Hugo - Tooling written in interpreted languages like Python and TypeScript decays really quickly over time. The fact that Hugo was written in Go was a huge upsell for me. I, myself, have written several tools and have always felt that the code maintainability of languages like Go is much higher than Python.
  4. Busybox - To minimize the attack surface even further, my final docker image contains HTML, CSS, Javascript, and only one binary busybox-httpd server. I don’t think one can cut the attack surface more than this.

How to migrate

Migrating isn’t easy. There are tons of caveat.

As a small sample of the items that one should be careful while migrating,

  1. I wanted to preserve the location of the feeds.
  2. I wanted to preserve the GUID of the entries.
  3. I wanted to download associated files e.g. media.
  4. I wanted to migrate tons of external embeds, like YouTube embeds, Google Maps embeds etc.

I looked at several tools, none migrated these properly. So, I ended up writing wp2hugo. wp2hugo made it to the Hacker News’s frontpage!

This is a common concern that people make about static sites. And that’s a valid one. Most Hugo users seem to use Disqus for this. I migrate to Remark42, a system that can be deployed an self-hosted. Since, this uses a file-based comments system, I mounted a single Google Cloud Storage (GCS) bucket as a directory to persist the comments. And then Remark42 itself can be deployed as a separate docker image.

Current status

The new site is up and running at https://v2.ashishb.net/.
For now, the old site is still running at https://v1.ashishb.net/ but will be shut down in a few days.