Make Default Canonical remove trailing slash

#99229
  • Resolved David
    Rank Math free

    Hello,

    I would like that all default canonical URLs (products, pages…) to remove the slash “/” at the end.
    I’ve got the opposite issue to this post : https://support.rankmath.com/ticket/make-default-canonical-include-trailing-slash/#post-99069
    So I guess the code should be quite similar.

    But first, I would have like to solve that without code.
    Why default canonical URLs don’t change by modifying permalink settings ?

    On Rank Math website it’s writen : “Even if you don’t set a canonical URL inside Rank Math, Rank Math will set the * post’s current URL* as the canonical URL of the page. Depending on your permalink settings, you might want to set a canonical URL yourself or change your permalink settings so that the default canonical URL is the one that works for you.”

    Is my unique chance to get it right was to have the good permalink setting before installing Rank Math ?

    If it’s not possible to solve this with permalink settings, I would need a code that will check if a canonical is already defined in Rank Math and if it is, it uses it. And if it is not, it takes the current canonical and if it has a slash at the end, it removes it.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I have seen my colleague already answered you in the other thread (https://support.rankmath.com/ticket/make-default-canonical-include-trailing-slash/#post-99069). Let us know here if it helps you and if not, we will continue helping you here (to avoid having our conversation along several threads).

    Looking forward to helping you. Thank you.

    ​​​​​​​

    David
    Rank Math free

    Alberto,

    I tried the code given by your colleague, it doesn’t work… There is still the trailing slash at the end.

    Alberto
    Rank Math business

    Hello,

    Then, I think we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    David
    Rank Math free

    Before that, just to make sure we’re talking about the same thing.

    My URLs don’t have slash “/” at the end.
    In advanced tab, I didn’t fill canonical URL field.

    But there is a URL by default already displayed in light grey with slash “/” at the end.
    I thought I read that this URL by default was taken into account, am I wrong ?

    Hello,

    I do believe we are in sync on what the issue is.

    Please follow the steps hared to create and shared so we can look into this further

    Looking forward to helping you. Thank you.

    ​​​​​​

    David
    Rank Math free

    Hello,

    Thank you for your reply.
    Sorry to ask again, but you didn’t answer my question. Does this default URL is taken into account ?

    Because there is something weird.
    When I analyse my website with the Google Chrome plugin SEO Minion, canonical URLs are displayed without slash “/”.

    Hello,

    The canonical URL in Rank math is usually self-canonical. This means that the canonical URL, unless modified, will always be the same as the page or post URL. If your posts don’t have a slash at the end, your canonical URL shouldn’t have any.

    To check the canonical assigned to your pages/posts, please check your page source for the canonical tag:
    img

    Looking forward to helping you. Thank you.

    ​​​​​​

    David
    Rank Math free

    Here’s the weird thing.
    As I was saying, I checked my canonical URLs and they are without the slash, so it’s fine for me.

    So there is a problem in Rank Math, because default canonical URLs still displaying with slash.

    Could it be due to the fact that my permalink settings were with slash before installing Rank Math, then I changed and Rank Math didn’t update default canonical URLs?

    Andy
    Rank Math pro

    I see the same as David, and whilst it does appear to push the right canonical out in the code, the fact that it displays the wrong one on the editing page is a bit confusing.

    To be clear: When I check the page source code it appears to include the canonical without the slash, but if I log in and look at the product, under the rank math / advanced section of the page, it shows a default canonical (in grey) which includes a slash on the end.

    Hello,

    Thank you for the follow up.

    The URL shown in canonical settings is just an input placeholder text not the actual canonical. It doesn’t define what is displayed on your page source. The canonical, as previously said, is automatically generated, which means it is generated for the post/page while it is being loaded not while editing the page.

    That said, the canonical that you should check and be concerned if it is not as expected, is the one shown in the front end of your page.

    Hope that clears the issue and please do not hesitate to let us know if you need our assistance with anything else.

Viewing 10 replies - 1 through 10 (of 10 total)

The ticket ‘Make Default Canonical remove trailing slash’ is closed to new replies.