Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2020-07-03 09:51:01

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

Re: Duplicate content

zero wrote #324230:

?whatever can appear anywhere. Try it at the end of any article url.

Indeed but why would anybody link to it?

Maybe if you define the canonical in the head, search engines will know

<txp:if_article_list>
<link rel="canonical" href="<txp:page_url context />" />
<txp:else />
<link rel="canonical" href="<txp:permlink />" />
</txp:if_article_list>

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

Offline

#26 2020-07-03 09:54:38

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Duplicate content

Yes, I know that Yiannis, but I’m stubbornly wanting to remove reliance on canonicals by using redirects and stripping away ?whatever instead.


BB6 Band My band
Gud One My blog

Offline

#27 2020-07-03 14:18:03

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

Re: Duplicate content

zero wrote #324232:

Yes, I know that Yiannis, but I’m stubbornly wanting to remove reliance on canonicals by using redirects and stripping away ?whatever instead.

I’m scratching my head but the cases may be too many. By default txp has ?q=, ?s=, ?c=, ?author=, ?id=… I hope I did not forget anything else expect to mention that there are more, generated by plugins.


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

Offline

#28 2020-07-03 15:09:24

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Duplicate content

Thanks for trying, Yiannis, I must be a very trying person! Oleg’s code in the head of default and archive pages (which are all I am using in this case) removes all those you mention from the url. The only exception I have found is that when I use search (the normal search_input) it works and even shows example.org/?q=searchterm as the url.

I can see how some plugins might use ?c=, ?s=, ?id=, ?author= and probably other strings but if I’m not using those particular ones, it’s not a problem. I’m using categories but colour-coding them and not linking them, so someone can use search to find a category of interest. So at the moment I have no duplicate lists of excerpts or articles and nobody can produce one via a category list or author list. So Gargoyle won’t find a duplicate either, canonicalized or not.

The only problem I’d like to overcome is to get comments working as expected. With Oleg’s code in place, comments are previewed and submitted. However, on Submit the visitor is taken to a 404 and doesn’t know her comment has been submitted.


BB6 Band My band
Gud One My blog

Offline

#29 2020-07-03 15:55:01

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

Re: Duplicate content

Oh, I must have forgotten about comments, sorry. Also, not sure about anchors. Could you try to replace <txp:page_url context /> with

<txp:page_url context="id, s, c, context, q, m, month, author, commented" />

and report back, please?

Offline

#30 2020-07-03 15:58:17

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

Re: Duplicate content

In txp versions prior to 4.8, I used to use the zem_redirect plugin which dealt with a lot of these issues. Unfortunately it no longer works for deeper structures. It may however work for you. It’s plug n play. Install it, enable it and all should be working as expected. Apologies for not thinking about it earlier.

> Edited to add that you may no longer need Oleg’s suggestion with this plugin which also protects from some script injections.

> Edit 2. Oleg was, as usual, faster with a native solution.

Last edited by colak (2020-07-03 16:04:11)


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

Offline

#31 2020-07-03 16:28:30

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Duplicate content

Ha ha! Friday afternoon. My internet is slow, I can’t view your videos yet, Yiannis, but this is making me laugh.

I tried the zem-redirect plugin but there are no instructions except for paying customers at threshold state, which no longer exists.

Perhaps we have crossed wires about Oleg’s code. I have been referring to

<txp:evaluate query='"<txp:site_url trim="/" /><txp:page_url type="req" />" != "<txp:page_url context />"'>
    <txp:txp_die status="404" />
</txp:evaluate>

I use that in my head (Edit: in the head of my page, not just in my own head which is also full of this stuff now!:-) along with Phil’s 4.8.1 TXP head code.

Regarding Oleg’s code when answering your slightly different question, Yiannis, ie

<txp:page_url context="id, s, c, context, q, m, month, author, commented" />

I’m not sure where that fits in with my problem. I think that’s for your scenario, Yiannis.

But it’s Friday afternoon so expect the unexpected.

Last edited by zero (2020-07-03 16:29:51)


BB6 Band My band
Gud One My blog

Offline

#32 2020-07-03 16:30:23

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

Re: Duplicate content

zero wrote #324241:

Ha ha! Friday afternoon. My internet is slow, I can’t view your videos yet, Yiannis, but this is making me laugh.

I tried the zem-redirect plugin but there are no instructions except for paying customers at threshold state, which no longer exists.

Indeed but the instructions might not be needed as it works out of the box. Having said that, try Oleg’s recommendation first.


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

Offline

#33 2020-07-03 16:31:32

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Duplicate content

colak wrote #324242:

Indeed but the instructions might not be needed as it works out of the box. Having said that, try Oleg’s recommendation first.

I don’t know why but I’m laughing my head off!

BTW, I’ve had no trouble with canonicals, they are all as expected or desired.

Last edited by zero (2020-07-03 16:38:39)


BB6 Band My band
Gud One My blog

Offline

#34 2020-07-03 16:46:10

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

Re: Duplicate content

zero wrote #324241:

I’m not sure where that fits in with my problem. I think that’s for your scenario, Yiannis.

I think that my issue was sorted. You can try

<txp:evaluate query='"<txp:site_url trim="/" /><txp:page_url type="req" />" != "<txp:page_url context="id, s, c, context, q, m, month, author, commented" />"'>
    <txp:txp_die status="404" />
</txp:evaluate>

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

Offline

#35 2020-07-03 16:54:21

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,470
Website

Re: Duplicate content

colak wrote #324244:

I think that my issue was sorted. You can try

<txp:evaluate query='"<txp:site_url trim="/" /><txp:page_url type="req" />" != "<txp:page_url context="id, s, c, context, q, m, month, author, commented" />"'>...

Aah! Now I’m kind of getting it, but it will take me a lot of studying to understand how this works and the penny finally drops.

Anyway, comments are now working as expected, all seems to be well, must get something to eat, will report back again after more tests later.

THANK YOU BOTH!


BB6 Band My band
Gud One My blog

Offline

#36 2020-07-04 09:48:15

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

Re: Duplicate content

etc wrote #324238:

Oh, I must have forgotten about comments, sorry. Also, not sure about anchors. Could you try to replace <txp:page_url context /> with

<txp:page_url context="id, s, c, context, q, m, month, author, commented" />...

and report back, please?

It works for my site but I also needed to add pg. Latest code

<txp:evaluate query='"<txp:site_url trim="/" /><txp:page_url type="req" />" != "<txp:page_url context="id, s, c, context, q, m, month, author, commented, pg" />"'>
    <txp:txp_die status="404" />
</txp:evaluate>

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

Offline

Board footer

Powered by FluxBB