How to set meta data of a page in Joomla
Joomla provides a built in class for setting up the meta data of a page in joomla. JFactory::getDocument() will be avaiable in Joomlaย for setup the meta data.
SEO is very important for all website so the meta data setup we can’t avoid on a web page. Just setting up the meta title ,description will not improve your page ranks should have proper content that match with these title and content.
Now we can discuss how to set meta data of a page in Joomla using JFactory:: getDocument() Class. its simply and easy to understand. From any page you need to set the meta data just make sure your created the JFactory ::getDocument() object.
How to setup the Page Title of page in Joomla using JFactory ::getDocument()
$document = JFactory::getDocument();
$document->setTitle("This is my page title");
How to setup the Meta title and Meta Description of page in Joomla using JFactory ::getDocument()
$document = JFactory::getDocument();
$document->setMetaData('title', "Your meta title");
$document->setDescription( "Your meta description" );
How to set up the keywords , author and robots etc using JFactory::getDocument()
$document = JFactory::getDocument();
$document->setMetaData('keywords', "keyword1,keyword2, etc.");
$document->setMetaData('robots', "index,follow");
$document->setMetaData('author', "Jobin Jose");
Older versions of Joomla required anย ” & ” like $document = &JFactory::getDocument();, latest version do not required this “&” just use us above. This will add the meta data on the top of the page.
Tips :- Page title always should be less than 70 characters.
- Meta description should be 150 to 160 characters.
Hope you will get an idea of Joomla meta data setting options. ๐ย ๐ย ๐
3 thoughts on “How to set meta data of a page in Joomla”
There is another part when you want to add any property to meta tag as:
$document->setMetaData('title', "Your meta title");
will do-
but there are cases(as in open graph, when you want to add property like –
For this you can use –
$document->setMetaData('og:type', 'website', 'property');,
or
$type='';
$document->addCustomTag($type);
Thanks for the tips ๐
Thanks.
Worked for me on some Fabrik generated details pages. Very useful for SEO eg: http://glutenfreedietfinder.com.au/index.php?option=com_fabrik&view=details&formid=5&rowid=318-careme-pastry
I had to create and edit a custom template file in: //public_html/components/com_fabrik/views/details/tmpl/GFDF-details/default_group.php
and change the fabrik list settings to use this template.