First what we must do is signup for Google Webmaster Tools and Yahoo Site Explorer, Live Search still doesn’t have a webmaster console where you can add sitemaps (they did announce one is in the making).
Then we verify ourselves using their verification methods. Once verified we can continue adding our sitemap, but we still can't do that cause we must first construct our sitemap, so let's make it. We can begin by making a template group called ‘sitemap’. Why you say? Well since Google and Yahoo allow you to add multiple sitemaps, you can basically make for each section or weblog a sitemap. This is useful cause as we all know a sitemap can only have a maximum of 50.000 URLs or 10mb in size. So this way you can manage different sitemaps with one template group. This method can also be used when you want to assign different priorities for different sections of your site, you can make a sitemap for each of those sections with their own unique priority and settings.
Now that we have made our template group we can start making our template. Press the ‘New Template’ link to make a new template, we will name it ‘articles-sitemap’ and set the template type to ‘RSS Page’ and hit submit.
Click on the newly created template so we can start editing. Paste the following inside of your template:
{assign_variable:weblog_name="default_site"} <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>{homepage}</loc>
<lastmod>{exp:stats}{last_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}{/exp:stats}</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>#br#
{exp:weblog:entries weblog="{weblog_name}" limit="500" disable="categories|custom_fields|member_data|pagination|trackbacks" rdf="off" dynamic="off" status="Open"}
<url>
<loc>{title_permalink="{template_group_name}/comments"}</loc>
<lastmod>{gmt_edit_date format='%Y-%m-%dT%H:%i:%s%Q'}</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>
{/exp:weblog:entries}
</urlset>
{assign_variable:weblog_name="default_site"}
<loc>{homepage}</loc>
<lastmod>{exp:stats}{last_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}
{/exp:stats}</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
{exp:weblog:entries weblog="{weblog_name}" limit="500"
disable="categories|custom_fields|member_data|pagination|trackbacks"
rdf="off" dynamic="off" status="Open"}
<loc>{title_permalink="site/article"}</loc>
{comment_url_title_auto_path}
<lastmod>{gmt_edit_date format='%Y-%m-%dT%H:%i:%s%Q'}</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
According to Google's and Yahoo's new sitemap rules, their sitemap tool does not accept URLs from a higher level or a different level.
http://www.mydomain.com/sitemap.php (ACCEPTED)
http://www.mydomain.com/sitemaps/sitemap.php (NOT ACCEPTED)
A simple work around makes our day.
Step 1: Create a ‘sitemap.php' file (you can name it anything you like, but keep the .php extension)
Step 2: Paste the following code into the sitemap.php file:
<?php
// Prevent content to be cached
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Content was generated on past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //Content is always modified
// Inform user agent that content is XML and is UTF-8 encoded
header('Content-type: text/xml; charset=UTF-8');
// Read content from template and show it
@readfile ('http://www.yoursite.com/index.php/weblog/sitemap/');
?>
This is a quick way of generating a sitemap of your site. There is always room for you if your site is very big to make more custom sitemaps. We can also generate a sitemap for your static pages or regular templates but this I will cover in another tutorial.