Redirect to Ghost / New structure without loosing Google ranking

Hi there

I’m a newbie with Ghost and just transferred my most important posts to it. As I want to get rid of all the old WP Stuff, I just copied the Article in Post and Pages in Ghost. My question is now related to Redirect

My old blog is running under https://xzy.net/blog. In Ghost I would like to have my Posts in the folder /magazin

How can I achieve this without loosing any seo ranking in Google? Is implementing a redirect the right thing in this case?

Whats about the dynamic routing

I’ll will also use tags. Does this have any influence in the structure of the url?

The second question related to this is what happend to old URL which will not exist anymore in the near future? Will those links automatically going to a 404 page? If not how can I set this up?

Sorry for the silly questions. I read both articles but I didn’t get it how to do it properly in my case.

Thank you so much for your help in advance. It’s really appreciated!
Reto

Hey there!

In order for redirects to work as you expected you’re going to need to put your Ghost site at xyz.net and then setup redirects that pattern match /blog/ urls and redirect them to /magazin/. Tags have their own urls, do you have tag pages that you want to redirect as well? Those can be done in a similar manner. The tutorial page you linked to explains about the use of regex, check out that link for for more information.

Hope this helps!

Hi DavidDarnes

Thank you for pointing me in the right direction.

Basically I have just to change the path in this file, which I found already in Settings/Lab.

{
  "from": "/https://xyz.net/blog/" ,
  "to":  "/https://xyz.net/magazin/",
  "permanent": true
}

I assume, that every post needs to have the tag "magazin". Thats it?

Great platform. I love Ghost already!

Thanks
Reto

That syntax isn’t right, you’ll want it like this:

[
  {
    "from": "/blog/" ,
    "to":  "/magazin/",
    "permanent": true
  },
  {
    "from": "/blog/(.*)",
    "to": "/magazin/$1"
  }
]

The first item deals with the root page, the second deals with all items under that path.

By default Ghost places all posts under the root, and tags won’t add the prefix of /magazin/ to post urls. Check out our documentation on routes.yaml https://ghost.org/docs/api/v2/handlebars-themes/routing/#base-configuration You’ll probably want to do something like this:

collections:
  /:
    permalink: /magazin/{slug}/
    template: index

This will adjust the default url of posts to be prefixed with /magazin/. Hope this helps!

Thank you David

I’ll try this today or tomorrow and let you know how it worked. Looks complicated. I’m more the creative and not the coder person. :slight_smile:

Kind regards
Reto

1 Like

Quick question. How would the code be if I want to redirect to /magazin and /irland-reisetipps instead of blog. Would it be possible?

Thank you!
Reto

I’m not sure what you mean? You can’t redirect to two different urls, it would have to resolve to one url

Hi there

Finally the move to Ghost was successful, related to the fact that the site is up and running on Ghost :grinning:

Unfortunately I struggle with the redirect to my posts and pages. What I did was to change the file as suggested by David.

[
{
“from”: “/blog/” ,
“to”: “/magazin/”,
“permanent”: true
},
{
“from”: “/blog/(.*)”,
“to”: “/magazin/$1”
}
]

It seems to be working as there is a redirect, but not the right one as I‘m getting 404 Error Messages.

An example. One of my posts appears in Google with the following URL

https://www.irlanderleben.net/blog/mit_der_faehre_nach_irland/

When I click I‘ll get the 404 with this URL in the Browser

https://www.irlanderleben.net/magazin/mit_der_faehre_nach_irland/

It looks like the redirect is right with the slug /magazin/ in there.

But the post has effectiv the URL

https://www.irlanderleben.net/mit_der_faehre_nach_irland/ (without the slug magazin)

I used the Tag Magazin in the Post. I read all the post about tagging and redirect but I don‘t get it…

Any help with this is very welcome and appreciated. What do I have to change to point google to the right url?

Thanks
Reto

Hey there, did you update your routes file as well? I mentioned it in my previous comment:

Hi David

I tried this in the meantime. If I replace your code in routes.yaml every single click is going to a 404 page. It doesn’t matter if I’m coming from google or try to open a post internaly.

I switched back to the original code in the file:

routes:

collections:
/:
permalink: /{slug}/
template: index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

the collection with the tag magazin seems to be display properly
https://www.irlanderleben.net/tag/magazin/irland-reisetipps/

But all my post didn’t contain the tag /magazin

I read somewhere that tags didn’t display in the url. Correct?

This is the current code in my redirects file.

[{“from”:"/blog/",“to”:"/magazin/",“permanent”:true},{“from”:"/blog/(.*)",“to”:"/magazin/$1"}]

how do I have to code the routes file correctly to get the desired result?

Thank you very much
Reto

OMG!

I had a light-bulb moment and just added /magazin in the original file:

routes:

collections:
/:
permalink: /magazin/{slug}/
template: index

taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/

And guess what it works! F… me pink like a Flamingo: I’m a coding genius now :joy:

2 Likes

I’ll assume that worked :sweat_smile:, glad to hear it

Brilliant, thank you for your help David.

Additional question. I plan to use another tag. I learned that there is one main tag in Ghost. Which is for me magazin. I have now my posts added first magazin and in some post as second tag reisetipps.

Those posts should appear as a collection. I entered this url in “design” to the navigation menu
https://www.irlanderleben.net/tag/magazin/irland-reisetipps/

But I’m getting a 404 message then. Which is the correct url to see the collection page?

Thank you
Reto

That’s not the right link, for tag collections you just want to see here
https://www.irlanderleben.net/tag/magazin/