Skip navigation

CrispCreations

always under construction

Xaraya Techniques
Home > XarDev > Techniques >

SEO - prevent duplicate content using the themes meta block

 
Last modified on Sep 5, 2008 03:57:47 AM by Crisp [ #permalink ]

As well as looking at robots.txt, search engines like Googlebot look for meta tags to determine what to do when they arrive at a page. With use of the Themes module meta block, and some custom variables, it's possible to add this meta information dynamically, and prevent duplicate content appearing in listings.

What's it for?

Why might you want to do that? Well, let's say you have an article called 'SEO',  with an aid of 9, in the articles module belonging to a howto pubtype with a ptid of 2.

Depending on your url setup, that one article can be accessed by any or all of the following urls

?module=articles&aid=9

?module=articles&ptid=2&aid=9

/articles/9

/articles/howto/9

/articles/howto/SEO

/articles/SEO

/howto/SEO

/howto/SEO/9

/howto/9

/howto/SEO/02-02-08 12:00

That's 10 possible combinations which will return the content for a single page, you can see how easy it is to get duplicates. You can double that number by including index.php in the urls too.

Now, with a little template magic, we can decide if we're on the page we want the search engine to index, and have it ignore the others.

How to do it

First of all, we need the url for the page we want indexed. We can find this out by having Xaraya tell us what it should be, based on current settings. Taking the example above, we'd place this code in our articles user-display.xt template

All we've done there is get the URL xaraya would normally use to display the current page.

Now we get the current url we're actually at.

Now we have that information, we can use it to decide what we want search bots to do.

Now we just need to add a little code to the meta block template, over-ride themes/xartemplates/blocks/meta.xd in your theme and add the following code.

With that done, you can use the same compare to determine if other pages on your site should be indexed or not, all you need to know is the real display page you want indexed, and add the necessary check to your templates.

comments

Note: Comments are owned by the poster. We are not responsible for their content.

SEO - prevent duplicate content using the themes meta block

comment by St.Ego [ip: logged] on October 23, 2008 11:48 PM [ #permalink ]

How much do you think it helps to eliminate indexing of duplicates? I had often wondered about the best approach to this. It seems there should be a modular way to define, categorically, which URL's should be indexed. The rest would seem to need either a "moved" or "redirect" response pointing to the canonical name chosen, neh?

SEO - prevent duplicate content using the themes meta block

comment by Crisp [ip: logged] on October 26, 2008 01:58 AM [ #permalink ]

Speaking from personal experience, I noticed that Google stopped indexing pages, even ones which are ranked like the Headlines module download. Once I removed the duplicates, the pages were indexed again, so there's definitely some benefit to be had by doing it.

As far as a modular approach goes, I think there's a definite benefit to that method. If Xaraya could be persuaded to send redirect permanent headers for duplicates pointing at the correct URL, that would be the ideal for me.

I did consider doing the above check and then using response re-direct, but I wasn't sure how Google might react to that, so I went for the safe option of marking the pages that shouldn't be indexed, and just let Google figure it out.

SEO - prevent duplicate content using the themes meta block

comment by krzysz [ip: logged] on February 11, 2009 01:40 AM [ #permalink ]

Thanks for posting this technique. I had a few issues with meta.xt and adopted it like so:

<xar:if condition="xarVarIsCached('Blocks.mycache', 'noindex')">
<xar:set name="noindex">
xarVarGetCached('Blocks.mycache', 'noindex')
</xar:set>
<xar:else />
<xar:set name="noindex">0</xar:set>
</xar:if>
<xar:if condition="$noindex">
<meta name="META/ROBOTS" content="NOINDEX" />
</xar:if>

SEO - prevent duplicate content using the themes meta block

comment by Anonymous [ip: logged] on May 16, 2009 05:21 PM [ #permalink ]

Quick couple of hits on this...

Rather than injecting the Noindex tag, why not inject the
<link rel="canonical" href="#preferedURL!#" />
?

As an alternative, send a Header() response with a 301 in it.

I either case, it means if someone does link to a non prefered URL, the SE should get the hint.
It may als ohelp preserve any LinkValue/PageRank.
(obviously the Redirect is preferred :D)

.

Hard part - fathomining out which URL is right/wrong.

Autocrat

Post a new comment
Anonymous
antibotimage
Please enter the Anti-Bot Code

Can't read it? Click the image to generate a new code.

Share:
  • Blinklist
  • co.mments
  • del.icio.us
  • Digg
  • Fark
  • Furl
  • Google bookmarks
  • Ma.gnolia
  • Netscape
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Windows Live
  • Yahoo MyWeb
Home > XarDev > Modules >

SEO - prevent duplicate content using the themes meta block

 
 
[ Privacy Policy | Terms and Conditions | Contact Us | FAQ | Back to top ]