Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Offline
Re: Duplicate meta descriptions
etc wrote #313197:
It would strip all non-txp parameters from the current page URL. That would replace the whole Yiannis block with
<link rel="canonical" href="<txp:page_url type="canonical" />" />...
Hmm, yeah, that way, that could be nice :-) I’ve use a block like Yiannis for ages, but replacing it with a one-liner surely improves readability.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Duplicate meta descriptions
etc wrote #313197:
It would strip all non-txp parameters from the current page URL. That would replace the whole Yiannis block with
<link rel="canonical" href="<txp:page_url type="canonical" />" />...
That would be absolutely wonderful! How would the url look in the search results, category and section pages, all of which sometimes use the ?
.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Duplicate meta descriptions
colak wrote #313181:
Now, all I need is a way to detect the home page
Late to the party, here’s how I do it: <txp:if_section name="default">is home<txp:else />not home</txp:if_section>
Offline
Re: Duplicate meta descriptions
gaekwad wrote #313201:
Late to the party, here’s how I do it:
<txp:if_section name="default">is home<txp:else />not home</txp:if_section>
But but that also includes category pages, author pages and anything else that uses the default section template (e.g search).
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Duplicate meta descriptions
phiw13 wrote #313203:
But but that also includes category pages, author pages and anything else that uses the default section template (e.g search).
It does, I was intending to show an alternative to the block laid out here and I should’ve provided more context.
I’m now revisiting a back-burnered page scaffold I was building when AMP was growing in popularity (and before the backlash), and this is how I was figuring out what the page was in a massive if
/ else
mess. Warning: not for the faint of heart:
<txp:if_status status="200">
<txp:if_individual_article>
<link rel="canonical" href="<txp:permlink />">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:permlink /><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<txp:if_section name="">
<txp:if_category>
<link rel="canonical" href="<txp:site_url />category/<txp:category />">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url />category/<txp:category /><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<txp:if_author>
<link rel="canonical" href="<txp:site_url />author/<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace>">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url />author/<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<txp:if_search>
<link rel="canonical" href="<txp:site_url />category/<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace>">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url />category/<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<link rel="canonical" href="<txp:site_url />">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url /><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
</txp:if_search>
</txp:if_author>
</txp:if_category>
<txp:else />
<txp:if_category>
<link rel="canonical" href="<txp:site_url /><txp:section title="0" />/category/<txp:category />">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url /><txp:section title="0" />/category/<txp:category /><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<txp:if_author>
<link rel="canonical" href="<txp:site_url /><txp:section title="0" />?author=<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace>">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url /><txp:section title="0" />?author=<txp:rah_replace from=' ' to='+'><txp:author title='0' /></txp:rah_replace>&<txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<txp:if_search>
<link rel="canonical" href="<txp:site_url /><txp:section title="0" />?q=<txp:rah_replace from=' ' to='+'><txp:search_term /></txp:rah_replace>">
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url /><txp:section title="0" />?q=<txp:rah_replace from=' ' to='+'><txp:search_term /></txp:rah_replace>&<txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
<txp:else />
<link rel="canonical" href="<txp:site_url /><txp:section title="0" />
<txp:if_variable name="useAMP" value="1">
<txp:if_variable name="isAMP" value="0">
<link rel="amphtml" href="<txp:site_url /><txp:section title="0" /><txp:variable name='AMPQueryString' />">
</txp:if_variable>
</txp:if_variable>
</txp:if_search>
</txp:if_author>
</txp:if_category>
</txp:if_section>
</txp:if_individual_article>
</txp:if_status>
This might be a fun project to resurrect for autumn.
Offline
Re: Duplicate meta descriptions
colak wrote #313199:
How would the url look in the search results, category and section pages, all of which sometimes use the
?
.
As I see it, that would preserve all txp parameters (q
, s
, pg
and so on) and remove all the others. That would also respect the current permlink mode.
But it could be more flexible to allow users to chose the parameters to keep, ideas welcome.
Offline
Re: Duplicate meta descriptions
etc wrote #313215:
As I see it, that would preserve all txp parameters (
q
,s
,pg
and so on) and remove all the others. That would also respect the current permlink mode.But it could be more flexible to allow users to chose the parameters to keep, ideas welcome.
One thing to keep in mind: for list / landing pages – as opposed to (individual) article pages – I set the canonical URL to the URL of the first page. Those pages are (usually…) subject to frequent changes and should not be indexed by search engines.
Take for example, Textpattern / blog. In my usage, the second/third/… page of this list (?pg=2
etc) would have the same canonical URL as the first page: https://textpattern.com/weblog
.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Duplicate meta descriptions
Okay, then we should leave with users the choice of “canonical” URLs (e.g. dump pg
). Which (new or existing) attributes of <txp:page_url />
could govern it?
Offline
Re: Duplicate meta descriptions
I would think that the escape
attribute would be a good one, so as to create w3 validated urls. ie escaping the &
.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Duplicate meta descriptions
That’s how it looks in the latest 4.7.2-dev:
<link rel="canonical" href="<txp:page_url context="id, s, c, author" />" />
will retain only the URL parameters specified in context
(a new attribute).
Offline