Fixing affliate links in Ghost

At some point (hopefully soon ...) I would like my blog to at least be able to generate some income. Getting off the ground is a bit of a pain. Google adsense has minimum content requirements, which after 6 months of weekly posting I still don't appear to have reached, and amazon have minium of 3 sales before you can properly become an affliate.

So, since my first time with Amazon has actually lapsed, need to re-apply. Can I re-use my old links? Hahaha. No. Mr Bezos needs more yachts. So, I now have the challenge of got though all my posts and changing the links on the older posts.

I had considered several ways but what if I don't want to actual hawk amazon products? Maybe I want to promote a different program? How do I update all my links quickly? What if I edit the database?

Editing the database has a couple of issues. The first one is I wanted something easy and striaght forward. Not something like dump the database, run some sed commands, re-import the database. I wanted something that was straightforward, easy to check all the links had been done and were correct. I also wanted to be able to change individual links should I need to.

This is where I stumbled upon redirects.yaml in ghost. This is currently in the labs section of the management console. The yaml file allows you to configure links and there redirects en--masse. In addition, if you are changing amazon affliate id, that could be done with a simple download, load in to a text editor, copy and replace and upload.

The syntax of the file is:

301:
  /af1: https://amazon.co.uk/

302:

301 or 302 relates to the type of redirect you wish to perform. In this case, I have set up a link for https://blog.php-systems.com/af1 to go to https://amazon.co.uk, using a 301 (permanent) redirect. A 302 redirect is temporary.

Now to go and update all the links in the blog....

Side Note: Got 404 urls on google search console due to old content? Redirect them to relevent pages or your index page.

Another side note, all the links now done. I did use the longer, full url from Amazon so they are easier to change in future. Sometimes, I am not a smart man...

As an Amazon Associate I earn from qualifying purchases.

If you have found this post useful, please consider donating.