---
title: "Refactoring your blog urls"
description: "I just did a quick refactoring of my JAMStack blog urls. Some didn't fit with my style, some had that I wanted to switch to , and others were ridiculously..."
date: 2020-06-11
published: true
tags:
  - blog
  - dev
  - webdev
template: blog-post
---


I just did a quick refactoring of my JAMStack blog urls.  Some didn't fit with
my style, some had `_` that I wanted to switch to `-`, and others were
ridiculously long.  I've been using forestry as my CMS, I write many of my
posts there, and sometimes it picks some crazy file names (based on my titles).
It was time to refactor.


<a href="/refactor-in-cli/" class="wikilink" data-title="Large Refactor At The Command Line" data-description="As projects grow patterns that worked early on break and we need to change things to make the project easier to work with, and more welcoming to new developers." data-date="2020-12-30">Large Refactor At The Command Line</a>

> When refactorings similar to this get really big I often need to do some
> project wide find an replace, I usually do this right from the command line.

## 🖊 Rename posts _change the filename_

My post urls are based on the file name of my markdown file, so I can simply go
through my filesystem and rename anything I want.  From here its probably best
to only commit the addition of the new file name, until the redirects clear,
but these are all low traffic posts for me so I just commited both at once.

> Safely redirect without breaking links

## _redirects ⤴ _/redirects_

I am hosted on netlify, which automatically puts very ⚡ performant redirects
on the edge based on a `/_redirects` route on your site.  So I added a redirect
from the old route to the new route there.

## rename long posts

``` bash
/blog/i-finally-fixed-my-styled-components-in-gatsby-js
/blog/fix-styled-components-in-gatsby
/blog/interrogate-is-a-pretty-awesome-brand-new-cli-for-python-packages
/blog/interrogate
```

## pedantic 🤔 _probably_

This is probably being a bit pedantic.  Realistically my urls were probably ok.
These posts probably aren't going to be topping the google search charts
anyways, but I wanted to do it without killing off any links that I may have
happened to post somewhere.
