Fix duplicate meta description errors in sNews with this quick hack

Comments (11)

Here's a nifty trick that I discussed recently in the comment section of one of my posts, but I think it's worth-while enough to bring to the front page on it's own.

You may have noticed that all the default "hard-coded" pages (archive, contact, sitemap) have the same meta description as the default for the website, this can cause duplicate meta errors to show up in Google's Webmaster Tools, and otherwise annoy SEO junkies. To fix this, BACK-UP your snews.php file, find the function title() and insert the following highlighted code;

function title() {
    global $categorySEF, $_DESCR, $_KEYW, $_TITLE, $_NAME, $_XNAME;
    echo '<base href="'._SITE.'" />';
    $url = explode('/',clean(cleanXSS($_GET['category']))); 
    if ($url['0'] == "tag" || $url['0'] == "search") {
        $title = $url['1'].' - ';
    } else {
        $title =  $_TITLE ? $_TITLE.' - ' : '';
    }
    switch ($url['0']) {
    case "tag":
        $_DESCR = "Viewing all entries tagged with the term; ".$url[1];
        break;
    case "tags":
        $_DESCR = "Overview all of tags used on the site"; // for tag overview, coming soon ;)
        break;
    case "search":
        $_DESCR = "Searching results for all items containing the term(s); ".$url[1];
        break;
    case "archive":
        $_DESCR = "View previous entries by date.";
        break;
    case "contact":
        $_DESCR = "Contact the website operator.";
        break;
    case "sitemap":
        $_DESCR = "Sitemap tree of all pages and articles on this site.";
        break;
    }
    
    $title .= $_NAME ? $_NAME.' - ' : '';
    $title .= $_XNAME ? $_XNAME.' - ' : '';

This also puts search terms and tags in the title, if you're using my SEO search mod or Tags mod. You may also want to change the language for the descriptions to your native tongue, and then upload your modified snews.php file and you should be all set.

bookmark / share this: Bookmark and Share
rated 3.5/5 (2 votes)


11 comments

Add a new comment »

Patric Patric said:
Mar 11th, 2009 at 1:10 am

Now this is a somewhat overseen dilemma fixed. Thank you


Matt Matt said:
Mar 11th, 2009 at 2:52 pm

Yeah, it's one of those things that's simple to fix, but doesn't get much notice until you see the errors.


jean jean said:
Mar 13th, 2009 at 1:39 pm

Thanks for this.
I don't think that the descriptions are as important as site content and external links to your site when it comes to SEO but seeing errors on the google webmaster page is unnerving and such a simple fix is appreciated.


Matt Matt said:
Mar 13th, 2009 at 3:04 pm

Thanks Jean,

I'm no SEO expert, so yeah, I don't know if it really matters as far as SERPs or anything goes, but I always tweak when GWT displays a number under the "issues" section of the content analysis, :P

The best part? I just checked mine, I have a new one... the "All items tagged with;" I put above is too short! Hahaha, I can't win!

So I just changed it to "Viewing all entries tagged with the term;" in my snews.php, we'll see if that soothes Google.


Tina Tina said:
Mar 23rd, 2010 at 6:02 pm

Hi Matt,
thanks for this, although as far as I can see it has been integrated into 1.7. It would be nice to have a proper Meta Description and Keyword field for Categories however. I have used the description field there for the meta description, but probably will need to add an extra meta_keywords field to the DB etc. to stop snews from taking the keywords from the main settings page.

Your page does not seen to have this problem. Have you fixed this issure for yourself?

best
Tina


Matt Matt said:
Mar 23rd, 2010 at 7:18 pm

Hi Tina,

I don't believe this has been integrated into sNews 1.7 at all, I have a test site running the latest 1.7 release (Update 1.5) and all the hard-coded pages (sitemap, contact,etc) still use the default site description.

As to my "fix" for categories keywords/descriptions... I haven't really fixed much :/

The categories by default use the description for each category and insert that as the meta description.

My category meta keywords are still the same default "site setting" keywords.

You are correct though, there needs to be a proper meta keywords field added to the DB for each category. If I get around to fixing this, I'll certainly post the how-to.


Matt Matt said:
Mar 24th, 2010 at 10:23 am

OK, I just did this mod on my test site, works fine, not too hard, I'm going to test it for a bit, then I'll implement it on my own site and see about writing up a tutorial.


Tina Tina said:
Mar 24th, 2010 at 7:12 pm

Hi Matt,
yes, I checked the orignal 1.7 again and as you say it's not implemented. I suppose I got confused. I have another hack implement which allows me to see the contact, sitemap, archive pages as "Pages" which I can thus edit. Thus, I can define META descs and META keywords for those. However, this is not the case for categories. I realise you mod above does more than just adding META Desc for those originally hard-coded pages.

It would be great, if you find the time to publish your mod for category META Keywords :)

At this point, I'd like to say ... Thank you very much for your great page and the hard work you have put into optimizing snews. Your hacks and mods have helped me a lot (I currently use the search engine mod, the archive mod etc.) and make it real fun to work with snews. Thank you so much for this :)


Matt Matt said:
Mar 26th, 2010 at 11:14 pm

Tina, give this a try;
http://www.mdj.us/snews-cms/hacks-mods/add-meta-keywords-to-your-categories-in-snews-17/

And thanks for the kind words, I do appreciate it :)


Bintang Sembilan Bintang Sembilan said:
Jul 22nd, 2010 at 10:00 am

Matt, thanks for your modd. I have apply it to my snewscms, but i have a problem with url. I have duplicate title tag for example:
http://teknologi.bintang9.co.cc/web/funny-logo-search-engine/
http://teknologi.bintang9.co.cc/web/funny-logo-search-engine

How can prevent it?


Matt Matt said:
Jul 24th, 2010 at 8:16 pm


Write a comment

* = required field

:

:

:

:

You may insert urls in plain text, urls will be automatically linkified for trusted users and on seasoned posts only. All first comments are moderated, so use your email if you want to be remembered.


Back to top