Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2018-08-01 12:38:24

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

Re: Duplicate meta descriptions

phiw13 wrote #313195:

What would it bring to the table?

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" />" />

Offline

#14 2018-08-01 12:52:40

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

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

#15 2018-08-01 12:58:51

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

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

#16 2018-08-01 13:05:09

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

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

#17 2018-08-01 13:09:30

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

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

#18 2018-08-01 13:36:41

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

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

#19 2018-08-01 17:50:47

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

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

#20 2018-08-02 00:09:59

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,081
Website

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

#21 2018-08-02 16:33:56

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

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

#22 2018-08-03 05:35:42

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

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

#23 2018-10-17 20:06:24

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

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

Board footer

Powered by FluxBB