2

I just updated my site to use pretty URL structures.

Old URL: https://digimoncard.io/deck/?deckid=1241
New URL: https://digimoncard.io/deck/green-otk-1241

I've set up my SEO like so:

<meta property="og:url" content="https://digimoncard.io/deck/green-otk-1241" />

<link rel="canonical" href="https://digimoncard.io/deck/?deckid=1241" />

Would this be considered correct practice? Currently, Google has the old-style URLs indexed and I want to avoid duplicate content SEO issues.

However, I'm not entirely sure if the query string URL should be in canonical or if it should be the other way around?

1 Answer 1

2

The canonical URL should be the current URL. so your code between <head> codes should be like this in the new URL:

<meta property="og:url" content="https://digimoncard.io/deck/green-otk-1241" />
<link rel="canonical" href="https://digimoncard.io/deck/green-otk-1241" />

If your old URL is you need to make a permanent 301 redirect to your new URL.

https://digimoncard.io/deck/?deckid=1241 > https://digimoncard.io/deck/green-otk-1241
5
  • 3
    Ah so an actual redirect is needed. I was hoping to avoid that. My concern is that I have over 1200 decks links and the title of the deck could potentially change when a user makes an edit to the deck. Doing so would then render my hardcoded redirect stale Aug 25, 2021 at 10:12
  • 2
    Although on second thought, maybe the pretty URL shouldn't be updated when a user edits the deck.. Aug 25, 2021 at 10:13
  • 2
    @genesisbits your old urls are indexed in google. If Google gets a 404 error when entering these pages, it means SEO problem and traffic loss for you. Also, when a user clicks on a link, the room will get a 404 error. If you have changed the URL, you have to do a 301 redirect. Aug 25, 2021 at 10:16
  • 1
    Aside: "htaccess 301 redirect code" - this code is incorrect. The Redirect directive does not match the query string (or scheme + hostname). For this, you would need to use mod_rewrite instead. See my answer to the follow-up question on Stackoverflow.
    – MrWhite
    Aug 26, 2021 at 1:00
  • 1
    If both the old URL and the pretty URL serve the same content and have a canonical tag pointing to the pretty URL you don't need to implement a redirect. However, a redirect is a stronger signal to Google compared to a canonical tag and Google is more likely to always use your pretty URL when you have a redirect compared to relying on the canonical tag. Aug 26, 2021 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.