Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#21 2020-07-03 06:28:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,159
Website

Re: Duplicate content

That indeed appears to be working! Thanks so much Oleg.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#22 2020-07-03 08:09:23

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

Re: Duplicate content

When I said Oleg’s code worked perfectly for me, I had not tested submitting a comment.

I’ve tried this:

<txp:variable name="foo" value='<txp:permlink />"?commented=0#txpCommentInputForm"' />
<txp:if_variable name="foo">
<txp:else />
<txp:evaluate query='"<txp:site_url trim="/" /><txp:page_url type="req" />" != "<txp:page_url context />"'>
    <txp:txp_die status="404" />
</txp:evaluate>
</txp:if_variable>

This doesn’t go to the 404 but also the txp:evaluate stops working.

Is there a way to allow comment submissions but still trim all other ?whatever from the url?


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#23 2020-07-03 09:42:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,159
Website

Re: Duplicate content

zero wrote #324228:

Is there a way to allow comment submissions but still trim all other ?whatever from the url?

I would think that ?whatever type urls only appear in article lists and comments only usually appear in individual articles, so you could enclose the code in txp:if_article_list.

Last edited by colak (2020-07-03 09:47:05)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#24 2020-07-03 09:47:53

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

Re: Duplicate content

colak wrote #324229:

I would think that ?whatever only appears in article lists, so you could enclose the code in txp:if_article_list

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


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,159
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
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,313
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.


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,159
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
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,313
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.


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

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

etc
Developer
Registered: 2010-11-11
Posts: 3,768
Website

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: 8,159
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB