Search code examples
phpwordpresscanonical-link

Why would wordpress output canonical URLs with %pagename% instead of the path?


Somehow my wordpress installation shows a canonical link in <head> that has %pagename% instead of the actual path. The home page works fine since it has no path required. All other pages have that %pagename% "variable".

There is an example of how it looks like:

<link rel="canonical" href="https://diverserealty.team/%pagename%/">

I would imagine that one of the plugins I have installed is the culprit, but I'm wondering how can I go by finding what the offensive code is and fix it? I'm not familiar with the WordPress environment, so a little hand would be greatly appreciated to accelerate the source of the problem!


Solution

  • I have determined and talked with the author of the Polylang plugin. The module changes many links as it has to make sure to include the language information in each link.

    One of the function would cache a link (the wrong one I had up there) and on the second call, when it tried to put that link in the header for the canonical link, it would used the cached value that included the %pagename% tag.

    Since then the code has been changed quite a bit.