Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-12-17 06:39:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

[SOLVED] canonical urls in search results bug?

I know that it is questionable if search results should have canonical urls but I have this meta tag for them:

<txp:if_search>
<link rel="canonical" href="<txp:site_url trim="/" /><txp:page_url />" />
</txp:if_search>

the parsed result of which is

<link rel="canonical" href="http://www.site.tld/?m=any&amp;q=query" />

Copying and pasting the url returns a 404 because of the &amp;. I think that the result should be:

<link rel="canonical" href="http://www.site.tld/?m=any&q=query" />

Would it validate though?
I also tried

<link rel="canonical" href="<txp:site_url trim="/" context /><txp:page_url />" />

which again returned the same url


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2019-12-17 15:13:04

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [SOLVED] canonical urls in search results bug?

colak wrote #320578:

I think that the result should be:

<link rel="canonical" href="http://www.site.tld/?m=any&q=query" />...

Would it validate though?

I don’t think so. But it might be possible to get it with escape="", not tested.

Offline

#3 2019-12-17 15:27:43

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: [SOLVED] canonical urls in search results bug?

Interesting

<link rel="canonical" href="<txp:site_url trim="/" /><txp:page_url escape="" />" />

validates just fine! I guess that the validator understands the content!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2019-12-17 15:37:20

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [SOLVED] canonical urls in search results bug?

colak wrote #320588:

validates just fine!

Fine then :-)

Offline

Board footer

Powered by FluxBB