Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-03-03 15:14:18

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

SEO optimisations of blog article list

Just building a new website, it has a common blog structure – i.e. the www.example.com/blog is a paginated date context archive list of blogs (with excerpts) that link through to full blog articles.

I’ve been reading up on best current SEO indexing techniques and conclusions I have come to are:

1. index, follow and have a rel=canonical and rel=next on the first page of the date context archive list as follows…

<meta name="robots" content="index, follow, noodp, noydir">
<link rel="canonical" content="http://www.example.com/blog">
<link rel="next" content="http://www.example.com/blog/?pg=2">

2. noindex, follow and rel=canonical, rel="prev" and rel=next on the subsequent pages of the date context archive list as follows…

<meta name="robots" content="noindex, follow, noodp, noydir">
<link rel="canonical" content="http://www.example.com/blog/?pg=2">
<link rel="prev" content="http://www.example.com/blog">
<link rel="next" content="http://www.example.com/blog/?pg=3">

3. index, follow and rel=canonical on the full blog articles themselves (I don’t have prev/next article links within these full article pages as I don’t see any value in that to users – surely they have gone to this specific blog article because they are interested in it alone – so I also don’t need rel=prev and rel=next here either)…

<meta name="robots" content="index, follow, noodp, noydir">
<link rel="canonical" content="http://www.example.com/blog/example-blog-article">

This provides the optimal link juice to Google and other search engines.

By the way, I also noindex all category context lists and author context lists completely because they just replicate info in the date context list anyway (just in a different sorting).

So my question is, how do I use Textpattern tags to check if this is page 2 or page 3 (i.e. not page 1 of an archive list)? So I can then provide the appropriate meta tags. Cleanest solution possible, avoiding deep tag nesting and without using plugins?

Cheers for any help!

Last edited by philwareham (2015-03-04 12:30:10)

Offline

#2 2015-03-03 15:24:30

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

Re: SEO optimisations of blog article list

Try this:

<txp:variable name="page" value='<txp:page_url type="pg" />' />
<txp:if_variable name="page" value="">
	default page
<txp:else />
	other pages
</txp:if_variable>

Maybe you will need to check <txp:if_variable name="page" value="1"> too.

Offline

#3 2015-03-03 15:45:43

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: SEO optimisations of blog article list

Thanks Oleg, that’s perfect!

So, for reference, code example is as follows, yes?…

<txp:if_article_list>

    <txp:variable name="page" value='<txp:page_url type="pg" />' />
    <txp:variable name="prev" value='<txp:newer />' />
    <txp:variable name="next" value='<txp:older />' />

    <txp:if_variable name="page" value="">
        <meta name="robots" content="index, follow, noodp, noydir">
        <link rel="canonical" href="http://www.example.com/blog">
    <txp:else />
        <meta name="robots" content="noindex, follow, noodp, noydir">
        <link rel="canonical" href="http://www.example.com/blog/?pg=<txp:page_url type="pg" />">
    </txp:if_variable>

    <txp:if_variable name="prev" value="">
    <txp:else />
        <link rel="prev" href="<txp:variable name="prev" />"
    </txp:if_variable>

    <txp:if_variable name="next" value="">
    <txp:else />
        <link rel="next" href="<txp:variable name="next" />"
    </txp:if_variable>

<txp:else />

    <meta name="robots" content="index, follow, noodp, noydir">
    <link rel="canonical" href="<txp:permlink />">

</txp:if_article_list>

Also, is this the best optimisation?…

<link rel="canonical" href="http://www.example.com/blog?pg=<txp:page_url type="pg" />">

Or calling the variable instead of tag (since we’ve already loaded it anyway)

<link rel="canonical" href="http://www.example.com/blog?pg=<txp:variable name="page" />">

I’ll add the final answer into the the v4.6 public theme for future reference.

Edit: corrected txp:newer and txp:older tags. Optimised performance.

Last edited by philwareham (2015-03-04 09:27:20)

Offline

#4 2015-03-03 17:58:54

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

Re: SEO optimisations of blog article list

Looks ok for me, save for <txp:if_variable name="page" value="1">: should be <txp:if_variable name="page" value="">. Also, <txp:next /> and <txp:prev /> tags do not exist, you certainly meant variables.

philwareham wrote #288724:

Also, is this the best optimisation?…

<link rel="canonical" href="http://www.example.com/blog?pg=<txp:page_url type="pg" />">...

Or calling the variable instead of tag (since we’ve already loaded it anyway)

<link rel="canonical" href="http://www.example.com/blog?pg=<txp:variable name="page" />">...

I don’t think there is a noticeable difference, both are light txp tags. <txp:page_url type="pg" /> could even be faster, because <txp:variable /> is always calling the parser (why?).

Offline

#5 2015-03-03 22:02:42

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: SEO optimisations of blog article list

Ah, those erroneous <txp:next /> and <txp:prev /> should have been <txp:older /> and <txp:newer /> tags – corrected those now in the example. Silly me.

Here’s a weird thing I noticed (doesn’t affect the functionality though, but thought I’d mention):

On the first page of an article listing when accessed directly it’d just be URL:

http://www.example.com/blog/

Then the next paginated page via <txp:older /> is, as expected URL:

http://www.example.com/blog/?pg=2

Now if you click the prev page via <txp:newer /> you get a URL:

http://www.example.com/blog/?pg=0

I’d expect that to be /blog/?pg=1 or simply /blog/. Why’s that then?

Anyway, as I said, that doesn’t affect functionality of the code example above because we are using noindex on any pages with a ?pg= pattern, but it seems a strange pattern choice to me.

Offline

#6 2015-03-03 23:17:55

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

Re: SEO optimisations of blog article list

philwareham wrote #288727:

Ah, those erroneous <txp:next /> and <txp:prev /> should have been <txp:older /> and <txp:newer /> tags – corrected those now in the example.

Here I would suggest <txp:variable name="next/prev" /> — they are faster. :)

Now if you click the prev page via <txp:newer /> you get a URL:

http://www.example.com/blog/?pg=0...

I’d expect that to be /blog/?pg=1 or simply /blog/. Why’s that then?

Looks like a recent bug/feature in join_qs function, please report.

Offline

#7 2015-03-04 09:39:40

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: SEO optimisations of blog article list

Thanks for the help Oleg, most appreciated!

Offline

#8 2015-03-04 12:18:50

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

Re: SEO optimisations of blog article list

Glad to help you to help us all, Phil!

etc wrote #288728:

Looks like a recent bug/feature in join_qs function, please report.

It’s not so recent in fact. I guess, now 0 should be replaced by empty string here.

Offline

#9 2015-03-04 12:27:19

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: SEO optimisations of blog article list

Let me know what to change this to:

$nextpg = ($pg - 1 == 1) ? 0 : ($pg - 1);

And I’ll then fix it.

Offline

#10 2015-03-04 12:47:21

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

Re: SEO optimisations of blog article list

This should fix it:

$nextpg = ($pg - 1 == 1) ? '' : ($pg - 1);

Offline

#11 2015-03-04 13:25:55

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: SEO optimisations of blog article list

Thanks, fixed now.

Offline

#12 2015-03-04 18:30:53

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

Re: SEO optimisations of blog article list

Question, answer, bug found, squashed, fix committed.

Great thread.

Offline

Board footer

Powered by FluxBB