WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
Canonical Link Trailing Slash Missing for Homepage (6 posts)

  1. Bryan Hadaway
    Member
    Posted 9 months ago #

    Can you please add a homepage conditional to insert the missing /?

    Thanks

    http://wordpress.org/plugins/all-in-one-seo-pack/

  2. Peter Baylies
    Member
    Plugin Author

    Posted 9 months ago #

    Bryan,

    The canonical link should be set to the permalink for the page in question; is this not working for you? What is your website and how do you have your home or front page set up?

  3. Bryan Hadaway
    Member
    Posted 9 months ago #

    This is an issue with permalinks set as Post name (most popular) on several sites, but I'd imagine it exists regardless for all permalink options.

    This isn't an isolated issue, this is a universal problem with WordPress canonicalization that has effected many canonicalization plugins for years now. It often goes overlooked because most people don't see the issue as it's under the hood.

    The problem is that the site URL is set as:

    http://wordpress.org

    Without the trailing slash because all permalinks, folder images, etc provide their own beginning slash to complete the URL:

    /contact/

    So, you'd have a proper canonicalization of:

    http://wordpress.org/contact/

    But, for the homepage, when you request:

    <?php get_site_url(); ?>

    or:

    <?php echo site_url(); ?>

    or:

    <?php bloginfo('wpurl'); ?>

    Or whatever, it just outputs http://wordpress.org - which for all other purposes is perfect for WP needs, but in the case of canonicalization, is erroneous.

    So, basically, just a simple is_home or similar conditional is needed to incorporate the trailing slash when needed.

    Thanks

  4. Peter Baylies
    Member
    Plugin Author

    Posted 9 months ago #

    Bryan,

    So basically what you're saying is that instead of using the home option or home_url() function, you'd like to see this default to home_url('/') when is_home() is true (and not using a static front page). I think this is correct and I'll see if we can implement this, or if there are any circumstances where this wouldn't be desirable. In the meantime, though, you can do this on your site with the aioseop_canonical_url filter.

  5. Bryan Hadaway
    Member
    Posted 9 months ago #

    Yeah, it's strictly a root URL issue based on either the WordPress Address (URL) or Site Address (URL) settings, or both.

    One variable to keep a lookout for is probably when people setup in a sub-directly instead of the root like:

    http://website.com/blog/

    And the like.

    I'm not a programmer, so that's probably as helpful as I can be for this issue.

    Thanks for looking into this.

  6. jonwu
    Member
    Posted 2 months ago #

    I have this exact same issue. My site is at /blog/ but the canonical is /blog. This is a huge issue for Facebook in particular because it doesn't follow 301 redirects so people trying to share /blog/ fail when the Facebook crawler hits it and sees /blog as the canonical and then crawls /blog for the contents of the post which then gives nothing.

    I've temporarily fixed this by rewriting the page at the load balancer, but I'll guess that's not something most people can do or know how to do :)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.