Fix duplicate meta description errors in sNews with this quick hack

Fix duplicate meta description errors in sNews with this quick hack

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.

Tags

 

You might like

Comments


Now this is a somewhat overseen dilemma fixed. Thank you


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


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.


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.


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


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.


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.


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, this is one useful mod; there's one thing I don't really get though. Even though you provide a description for all of the cases, search included, the description for search results remains unchanged (the default site description that is). It's not to do with the page title (to fix that the SEO search mod is needed), I'm talking about the page description, which should actually read: "Searching results for all items containing the term(s); [here term]", but it doesn't. Pertinent information: I do use the tags mod (which works great, also with page titles, as promised), but not (yet) the SEO search mod.
Cheers, Gerry


Hi Gerry,

Yes, the above only works if you're using the "SEO search mod".

You could do it for the default sNews install by checking for the search_query variable. Something like;

if ($_POST['search_query']) {
$_DESCR = "Searching results for all items containing the term(s); ".cleanXSS($_POST['search_query']);
}


Thanks, Matt. It's working perfectly meanwhile, as I am also using the "SEO search mod". Just one thing: is it me or why reads the title "search term -- site title" instead of "search term -Search- site title"? I know this is actually the wrong article to comment on this, but it is not entirely off-topic, as we are concerned about SEO, or we would not talk about meta description errors in the first place.
Cheers, Gerry


Gerry,

That's just the default way sNews does it. It's all in the above mentioned title function if you want to re-arrange things, it shouldn't take too much effort I wouldn't think.

--Matt


(optional, not publicly displayed) (optional)

Copyleft 2002 - 2014 Matt Jones
Hand crafted with HTML5 & CSS3
↑ Back to top