• Resolved Alexis Wilke

    (@alexiswilke)


    Hey,

    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="https://www.internetaffiliate.com/11-ways-of-promoting-your-niche-website/" />

    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:

    https://my-server.internetaffiliate.com/11-ways-of-promoting-your-niche-website/

    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 15 replies - 1 through 15 (of 19 total)
  • yes, it would be nice to be able to skip the code framed by certain comments

    Thread Starter Alexis Wilke

    (@alexiswilke)

    Comments? That would mean your theme would need to know to add those comments… right? Not likely to happen, I think.

    yes, themes can be edited, so there is no problem with this )

    for example as here: https://lyncd.com/wpscmin/#install
    see section MARK SECTIONS OF HTML SO THAT THEY WILL NOT BE MINIFIED

    Thread Starter Alexis Wilke

    (@alexiswilke)

    Ah, I see it’s already implemented. For a well known link that should not be minified, though, I think it should be automatic. I think most people are going to miss that one!

    But of course a separate setting for disabling rel minifi, would also be useful to those who do not correct the theme codes!

    Thread Starter Alexis Wilke

    (@alexiswilke)

    On the other hand, the line that adds the canonical link looks like this:

    <?php wp_head(); ?>

    So I’m not too sure how I could add your comment just around that one link. On the other hand, all links should probably not be minimized in that sense. But the HTML code can still be minimized. So surrounding that php code with the <!--[minify_skip]--> and <!--[/minify_skip]--> “tags” is not all that great.

    Yes, the above said was written about a separate setting for rel cannonical

    About <?php wp_head(); ?>, my own plugin turns off wp_head () from worpdress and builds the necessary headers, only those that are needed.

    • This reply was modified 6 years, 6 months ago by alexman87.
    Plugin Author Tim Eckel

    (@teckel)

    Adding the trailing slash is xHTML, not HTML5. Are you really generating xHTML?

    Thread Starter Alexis Wilke

    (@alexiswilke)

    I don’t know if its generated or my browser, but that’s a detail that the tag is closed with a slash, right? My document starts with <!DOCTYPE html>, so HTML5.

    Plugin Author Tim Eckel

    (@teckel)

    With doctype HTML, you don’t use closing tags with void elements (self-closing tags). For example, in a link tag you would not add a /> at the end. That’s XHTML, not HTML. With a doctype of HTML, it’s WRONG to add the closing tags on void elements. Sure, it works, but it’s technically not correct and unneeded.

    For this reason, there’s even a setting in Minify HTML that removes the closing tags from self-closing tags. This saves 2 characters each time it’s done.

    If, however, you really want to be incorrect and use XHTML in HTML doctypes, you can turn off the switch in Minify HTML and it won’t touch your closing tags on self-closing tags.

    It wouldn’t surprise me at all if WordPress adds closing tags to self-closing tags when doing a wp_head(). Just because WordPress is doing it, doesn’t mean they know what they’re doing or it’s right.

    Thread Starter Alexis Wilke

    (@alexiswilke)

    How about concentrating on the real problem and not destroy the canonical link?

    Plugin Author Tim Eckel

    (@teckel)

    I don’t follow you. There’s a switch in Minify HTML to convert improper XHTML to HTML. If you want to keep the improper XHTML, simply turn off the switch. This has nothing to do with canonical links, it’s the self-closing tags that are not required with the HTML doc type.

    If this doesn’t help, please explain in detail what the issue is once you turn off the setting in Minify HTML that removes the self-closing tags in HTML.

    Thanks!

    Thread Starter Alexis Wilke

    (@alexiswilke)

    My problem is this when I ask your plugin to remove the protocol & domain:

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

    That’s wrong. Just a path is wrong for the href="..." attribute is wrong.

    I don’t care about the /> part. Please ignore that part. That’s not what I reported.

    The canonical path MUST be a full URL including protocol, domain, and path.

    Now, if I don’t turn on that feature, it works as expected, but of course all the other links also remain full, even those in anchors, etc. which could be optimized.

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