Reputation: 159
I'm having this issue with joomla 2.5 and the Meta robots tag.
Basically joomla has this black hole in it that doesn't matter what the URL is as long as you have a article id that is valid it will generate a page.
example:
http://www.clet.edu.au/dasfjahsd/sajfhas/61-afssfas
61 is a valid id so it will display a page however it is a wrong rendering of the page.
this will be the correct rendering for that article
http://www.clet.edu.au/online-study/whs-courses/diploma-of-work-health-and-safety
What i've came up with is, our website doesn't have any urls with numbers on it, so pretty much any url that has a number on it it's wrong... so i've done this code:
$(document).ready(function(){
var pathname = $(location).attr('href');
var NO_NUMB = new RegExp("[0-9]");
if (NO_NUMB.test(pathname)) {
$('meta[name=robots]').attr("content", "noindex, nofollow");
}
});
What it does, it checks for numbers on the url and changes the meta robots to noindex nofollow. That works in part, it changes the meta robots but only does it on the browser DOM and not straight on the source file.
So when you go on your browser and click inspect element you can se the noindex nofollow tag but when you click view source, you will see index follow...
According to google support, google looks at the page source not the DOM on the browser... so it will never see the noindex nofollow tag...
I'm wondering is there a way to do that on PHP so it changes the meta keyword on the source code not on the browser DOM?
cheers, dan
Upvotes: 2
Views: 948
Reputation: 8282
Try this ,
Instead of changing the meta data from Javascript try it from php. Joomla have a document class for this purpose.
$document = JFactory::getDocument();
$document->setMetaData('keywords', "keyword1,keyword2, etc.");
$document->setMetaData('robots', "index,follow");
$document->setMetaData('author', "Jobin Jose");
$document->setMetaData('title', "Your meta title");
$document->setDescription( "Your meta description" );
$document->setTitle("This is my page title");
For more details read article How to set meta info of Joomla page
Hope its helps..
Upvotes: 2