The-seo-framework: Homepage canonical includes trailing slash, whereas page URL does not

Created on 2 Jan 2018  路  4Comments  路  Source: sybrew/the-seo-framework

On the homepage the canonical includes the trailing slash i.e.
https://domain.com/
whereas the actual URL of the homepage does not include the trailing slash
https://domain.com
Is there a way to change this? It is only occurring on the homepage.

[Type] Support

Most helpful comment

Thanks @sybrew much appreciated regardless. You can close this here I will chase on WP and try and convince client.

All 4 comments

Hi @themightyant,

Some browsers tend to hide the trailing slash from the URL bar, even if it's virtually present.
In such cases, it'll often be visible again when you click on the address.

If you go to wp-admin/options-permalink.php, you'll have to activate and adjust the Custom Structure.
If the last character is a /, you can to remove it to achieve your goal. Because by doing so, you'll omit it on all pages.

Background information, "To slash or not to slash":
https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html

The function affected: user_trailingslashit()

Hi @sybrew thanks for the response.

Is there a way to remove the slash in the canonical link on the homepage ONLY.

I understand the point about browsers removing a slash and that the google link supplied, albeit 7 years old, says that both are equivalent on the homepage. However my client, also an SEO guy, is adamant that the canonical link needs to be without the slash on the homepage. I can't seem to figure out a way to do this. Any help greatly appreciated.

Hi @themightyant,

That's an assimilation I've never heard of before.
As WordPress uses 301 redirects to send the user (and robot) from example.com to example.com/, there should be no penalty nor benefit whatsoever. It also means that this can't be changed in TSF plugin because the canonical URL will then point towards a non-existing page (that redirects), so it'll then be harmful.

Regardless, we're simply outputting what WordPress provides. Therefore, you'd have to filter stuff that WordPress provides.
I highly advise against changing this behavior, because many related functions used by WordPress and plugins -- like the aforementioned user_trailingslashit() -- don't conditionally check for homepage entries.

I can't provide a concrete resolution that could achieve your goal, as anything I can come up with will induce bugs throughout your environment because of the assessments mentioned above.

So, I'm afraid you'll have to convince your client. Good luck!

Thanks @sybrew much appreciated regardless. You can close this here I will chase on WP and try and convince client.

Was this page helpful?
0 / 5 - 0 ratings