Fix duplicate meta description errors in sNews with this quick hack
filed under: sNews CMS / Hacks & Mods
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.
11 comments
Add a new comment »Categories
Recent Entries
Recent Comments
- Redbeard (I managed to get Vampire: The Masquerade - Bloodlines ...)
- Tina (Installed this today and working like a charm :) Thanks!)
- Tina (Thanks for this great mod :) Working on my site for quite a ...)
- konga (Hi Matt, if you plan to update it, please have a look into ...)
- David (Yo Matt, I have a problem, when I use this mod. ...)
- Dave (Have a Toshiba NB305. Win7 starter would not do screen ...)
- Daichisan (Howdy Matt, I dont really get it, whats ...)
- Matt (Mine is just customized further, that's all :) It just spits ...)
- Matt (David, Do you own or admin the server? Do you have exec ...)
Popular Entries
- Compact archives for sNews 1.7 (5/5)
- Light-weight related articles mod for sNews 1.7 (4.78/5)
- SEF / SEO search for your sNews website (4.75/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.67/5)
- Gravatar mod for sNews 1.7 (4.67/5)
- An improved tag cloud for sNews 1.7 (4.67/5)
- Image / math hybrid captcha version 2, vastly improved (4.64/5)
- Related Articles mod for sNews CMS, public beta release (4.6/5)
- An easy mod to create custom break titles for your sNews articles (4.6/5)
Mar 11th, 2009 at 1:10 am
Now this is a somewhat overseen dilemma fixed. Thank you
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.
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.
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.
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
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.
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.
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 :)
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 :)
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?
Jul 24th, 2010 at 8:16 pm
Bintang,
You need to re-direct the url, try this;
http://www.mdj.us/web-development/force-the-trailing-slash-on-your-urls-with-modrewite-and-htaccess/