← Back to Blog

Keep Your Old WordPress Links Working After the Move

Search results, old newsletters and other people's pages all point at your WordPress addresses. A _redirects file sends each one to its new page.

By , founder and sysadmin of Static Host UK

I'm Axel Segebrecht. I build privacy-first platforms, advise small businesses on AI governance, and create free tools for the neurodiverse community.

Your old addresses are spread across search results, old newsletters, social posts and other people’s websites. Change your URLs in a move without redirects and every one of those links ends on “page not found”. A 301 redirect tells browsers and search engines that the page has moved for good and where it went.

The easy way: keep the addresses

Hugo can produce the same address pattern WordPress used, so nothing needs redirecting. If your posts lived at /2024/05/12/spring-opening/, a [permalinks] setting of posts = "/:year/:month/:day/:slug/" in your Hugo config keeps them there.

Find your old addresses

WordPress sets its link format under Settings, then Permalinks. The common ones (WordPress documentation):

  • Post name: /sample-post/
  • Day and name: /2008/03/31/sample-post/
  • Month and name: /2008/03/sample-post/
  • Numeric: /archives/123
  • Plain: /?p=123

For a list of every page, open /wp-sitemap.xml on the old site before you switch it off. WordPress has published one there since version 5.5. An SEO plugin may have replaced it with its own, often at /sitemap_index.xml.

Write the redirects

On our hosting, a file called _redirects in your published output holds the rules, one per line: old path, new path and, optionally, the code. 301 is the default. On a Hugo site the file goes in static/_redirects (redirects documentation).

# An old dated post to its new home
/2024/05/12/spring-opening/   /blog/spring-opening/   301

# The old feed
/feed/                        /index.xml              301

# A section that has gone
/category/news/*              /blog/                  301

A trailing /* catches everything beneath a path and sends it all to one place. A site can have up to 500 rules.

Plain links are the awkward case. The post number sits in the query string, so every one of them has the same path, /, and a path rule can’t tell them apart. They all arrive at your home page.

Check them

Rules take effect on your next deploy. Try a handful of old addresses in a private browser window: browsers remember 301s for a long time, so a mistake you have already fixed can still show in your normal one.

Yesterday’s post covered what comes across in a move from WordPress, and what gets left behind.

Ready to Deploy?

Join Jamstack developers across the UK hosting their static sites with privacy and performance built in. Hosting is free for good, no credit card needed, with Plus features when you want them.