[TUT] How to custom meta tags in joomla website

Meta tags are a great way for webmasters to provide search engines with information about their sites. Meta tags can be used to provide information to all sorts of clients, and each system processes only the meta tags they understand and ignores the rest. Meta tags are added to the <head> section of your HTML page and generally look like this:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="Description" CONTENT="Author: A.N. Author, Illustrator: P. Picture, Category: Books, Price:  £9.24, Length: 784 pages">
<meta name="google-site-verification" content="+nxGUDJ4QpAZ5l9Bsjdi102tLVC21AIh5d1Nl23908vVuFHs34="/>
<title>Example Books - high-quality used books for children</title>
<meta name="robots" content="noindex,nofollow">


Google understands the following meta tags (and related items):

<meta name="description" content="A description of the page" />
<title>The Title of the Page</title>
<meta name="robots" content="..., ..." />
<meta name="googlebot" content="..., ..." />
<meta name="google" content="notranslate" />
<meta name="google-site-verification" content="..." />
<meta http-equiv="Content-Type" content="...; charset=..." />
<meta charset="..." >
<meta http-equiv="refresh" content="...;url=..." />

 

Then How to custome it?

1. Use Metakey SEO plugin

for example: SEOSimple native Joomla 1.5/Joomla 1.6/Joomla 1.7/Joomla 2.5 plugin Joomla SEO 2.5

or alot of SEO and Metadata extensions http://extensions.joomla.org/extensions/site-management/seo-a-metadata

2. Use template code following joomla API:

There are two ways you can modify what is written to your head section.

  • Use the JDocument methods to insert meta and script tags in the head section.
  • Hard code the meta and script tags directly in the template index.php file.

This article is about option number one. You first need to get an instance of the current document and call the methods to modify the head. The head section tags will be added before the page is rendered.

Related articles:

Top 5 Premium Joomla! Extensions for 2013

Top 10 Best Practices SEO After the penguin 4 update 2013

//First get the current document object
$doc = &JFactory::getDocument();

//Will create a empty generator meta tag. If you dont want
//everyone to know site is running on Joomla.
$doc->setGenerator();
//Sets the description meta tag
$doc->setDescription('some desc');
//sets the title tag
$doc->setTitle('Some Title');
//create a meta tag
$doc->setMetaData($name,$content);
//adds a linked style sheet
$doc->addStyleSheet('/path/to/file')
//adds a linked javascript or other type of script file
$doc->addScript('/path/to/file')
//add a custom tag. Use to add any kind of tag to the head section.
$doc->addCustomTag();
//Add custom javascript code snippet. Pass in javascript code and
//will add the <script> tags for you. Joomla places these snippets
//after placement of addScript() scripts.
$doc->addScriptDeclaration()
//Add custom css style snippet. Pass in css styles and will add
//the <style> tags for you. Joomla will place these styles after
//placement of addStyleSheet() styles.
$doc->addStyleDeclaration()

 

Be Sociable, Share!

Leave a comment