Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-12-31 00:30:11

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Finally asking: How do I stop duplicate URLS when using section tag

Hi fellow TXPers,

I have tried all sorts of things to solve this fundamental problem and I must be missing something.

In a typical scenario I have sections and sections have articles and I use something like <txp:section_list break="li" wraptag="ul" /> for the sections and something like <txp:article_list section='<txp:section />' /> for a list of the sections pages.

Excellent.

However when this produces something like…

Section1 Section2 Section2

Page1
Page2
Page3
Page4

…if I click on Section2 then I see Page1 of that section and my URL is http://example.com/section2, but if I click on Page1 then I see the same page but now my URL is the permlink to that page, e.g. http://example.com/section2/page1.

I find this not only annoying but worrisome from an SEO viewpoint and also problematic in some circumstances that I can’t remember (because I’ve lived with this for ages, like a stone in my shoe).

I solved this recently with a pretty convoluted solution, I used a form with <txp:section_list /> and in that form I use TXP code to work out the permlink to the pages for a section and in so doing, never allow <txp:section_list /> to produce it’s own links—in effect I am forcing /section type URLS to never be produced by the site.

Can someone put me out of my misery; is there a simple way to solve this problem (sub-question, did I explain that properly?)?

Thanks a lot in advance for any help, cheers, -Alan

PS: If anyone wants to see the code I created to solve (cludge-solve) this, let me know—that said I assume there is and elegant solution and so no one will want to see my work-around.

Last edited by alanfluff (2011-12-31 00:35:15)


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#2 2011-12-31 08:19:39

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: Finally asking: How do I stop duplicate URLS when using section tag

What you describe sounds like normal behaviour:

  • a link to a section landing page will be like http://example.com/section2, and
  • a permlink to an article in that section will be like http://example.com/section2/page1.

That would also be good from an SEO point of view.

I’m guessing here, but is it that in your setup you want the first “page1” to be the same as the section landing page? In that case I can see your SEO dilemma. If so, there are a few approaches:

  1. Make the first article a sticky article and show that with status="sticky" witihn your txp:if_article_list part of your page template. That will also take it out of the submenu of pages in that section, e.g. your list of articles starts with “page2”. You won’t then have a link to the permlink on your page.
  2. Alternatively in your txp:article_custom section='<txp:section />' ... tag (note: article_custom not article_list), use txp:if_first_article in your form or contained code to serve the section url rather than the permlink for the first article, e.g. <a href="<txp:if_first_article><txp:site_url /><txp:section /><txp:else /><txp:permlink /></txp:if_first_article>">.... This would keep “page1” in your articles submenu but link to it with the section url. Note that to effectively hide the page1 permlink from search machines you may need to catch this url duplication situation in other places of your site too, e.g. in your google sitemap or meta canonical url.

TXP Builders – finely-crafted code, design and txp

Offline

#3 2011-12-31 18:42:41

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: Finally asking: How do I stop duplicate URLS when using section tag

Thanks Jakob, great suggestions.

I wonder if in, say, TXP5, a <txp:nav /> tag would be a worthwhile addition, with these options available. I suppose there may be too many variations (e.g. people using categories for nav etc, etc) to make it sensible, but I do think that TXP internally (and hence strongly) allowing us to easily avoid cases such as:

Note that to effectively hide the page1 permlink from search machines you may need to catch this url duplication situation

…would be a valuable.

But that aside, I am now sure I have some great ideas to test thanks to your comments, cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#4 2012-01-03 22:02:43

kevinpotts
Member
From: Ghost Coast
Registered: 2004-12-07
Posts: 370

Re: Finally asking: How do I stop duplicate URLS when using section tag

I solved this recently with a pretty convoluted solution, I used a form with <txp:section_list />

In my world, this is best practice. I like crafting my own explicit URL structures. I find different tags produce different URLs, and doing this eliminates the middle man.


Kevin
(graphicpush)

Offline

#5 2012-01-04 15:03:37

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: Finally asking: How do I stop duplicate URLS when using section tag

In my world, this is best practice. I like crafting my own explicit URL structures. I find different tags produce different URLs, and doing this eliminates the middle man.

Good to know. Like ur new site btw.


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#6 2013-09-21 15:12:43

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Finally asking: How do I stop duplicate URLS when using section tag

Hello,
I dont want to start a new topic for my question because I think it is related somehow to this one.
Could you comment on a possible solution to how you can stop the drill down (unlimitedly) to http://www.site.com/about/about/about for example?

Offline

#7 2013-09-21 17:18:15

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Finally asking: How do I stop duplicate URLS when using section tag

What is your code that produces something like your example “http://www.site.com/about/about/about”?

BTW: The in the entry post mentioned tag <txp:article_list> doesn’t exist.

Offline

#8 2013-09-22 12:02:51

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Finally asking: How do I stop duplicate URLS when using section tag

GugUser wrote:

What is your code that produces something like your example “http://www.site.com/about/about/about”?

No special code – regular textpattern. Try any txp site. It does not redirect to 401 page but opens a section or article page like http://inbel.org/pix/pix/pix/pix Which is not good for seo.

Offline

#9 2013-09-22 12:11:53

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Finally asking: How do I stop duplicate URLS when using section tag

I can’t find in the navigation of your site an URL like inbel.org/pix/pix/pix/pix. Where Textpattern produces this?

Offline

#10 2013-10-26 20:28:36

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: Finally asking: How do I stop duplicate URLS when using section tag

GugUser wrote:

I can’t find in the navigation of your site an URL like inbel.org/pix/pix/pix/pix. Where Textpattern produces this?

Well, it doesn’t produce by itself. But it is supposed to return page 401 instead. Right?

Last edited by admi (2013-10-26 20:28:50)

Offline

Board footer

Powered by FluxBB