Support » Plugin: Minify HTML » Your code breaks the Canonical link

  • Resolved Alexis Wilke



    I just got warnings about many pages on my website not having a valid canonical link. Looking at it, I had the following tag:

    <link rel="canonical" href="/11-ways-of-promoting-your-niche-website/" />

    A valid canonical link is required to be a full path:

    <link rel="canonical" href="" />

    The option you offer, Remove relative domain from internal URLs, can’t be set to Yes or you lose a valid canonical link!

    I’d bet there are a few others like that which required to always use a full URL even if a relative URL could be valid.

    In case of Canonical, it is because it covers sub-domains. For example, I could have a copy of my page at:

    That copy could be on my server so I can run tests before changing my live website. But to make sure Google does not view that as a different website, I would use the same <link ...> as shown above.

    Anyway… makes me sad, I like the idea of having “clean URLs” instead of having the full domain + path in each anchor.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter Alexis Wilke


    And obviously it’s not resolved, since you did not change any code, it just cannot be resolved.

    Plugin Author Tim Eckel


    Okay, then turn off the switch for protocol and domain.

    The plugin can’t solve every unique situation. Instead, I’ve created settings which allow you to enable or disable certain features. In this case, turning off relative domains and/or protocol schemes should resolve the problem.

    There are switches because some features won’t work for everyone. Most people don’t need to use canonical links (I never have) and those that do are typically on a different domain, in which case the domain won’t be removed. It’s rare and quite odd that you would have a canonical link to the same domain.

    Sorry if this doesn’t work out perfectly for you, there’s probably another minify plugins that will accommodate you. One of the goals of Minify HTML is to be fast, lightweight, and not use bloated libraries. Trying to accommodate this unique case is outside the scope of the plugin.

    You may want to consider doing 301 redirects instead, as that’s what I’ve done for the hundreds of websites I’ve been a part of. Best of luck!

    Plugin Author Tim Eckel


    Oh, and the issue is resolved as there’s options in the plugin to set features that will resolve the problem. In other words, the solution doesn’t need code to be changed, you just need to click a couple boxes on your end. Not every problem requires a software fix, sometimes it’s operator error or operator education.

    Thread Starter Alexis Wilke


    My last argument about this one: The canonical URL is there with a default WordPress installation. So you should remove that feature altogether since it can’t work with a normal WordPress install. Or… maybe fix the code. 🙂

    Anyway, I’m fine on my end at this point so I won’t sweat it any more than that.

    • This reply was modified 4 years, 10 months ago by Alexis Wilke.
Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Your code breaks the Canonical link’ is closed to new replies.