Sitemap templates
Here’s a basic template for generating a Google Sitemap. See Wiki Sitemap for doing this for your wiki. Set the template type to XML Page. You can change the values in red, see the Protocol for more info.
{assign_variable:master_weblog_name="default_site"}{assign_variable:template_group_name="weblog"}<?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="{DATE_W3C}"}{/exp:stats}</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
{exp:weblog:entries weblog="{master_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="{DATE_W3C}"}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
</url>
{/exp:weblog:entries}
</urlset>
If you want the last 30 entries on your blog to get a higher priority or be crawled more frequently than older entries:
{assign_variable:master_weblog_name="default_site"}{assign_variable:template_group_name="weblog"}<?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="{DATE_W3C}"}{/exp:stats}</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
{exp:weblog:entries weblog="{master_weblog_name}" limit="30" 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="{DATE_W3C}"}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
{/exp:weblog:entries}
{exp:weblog:entries weblog="{master_weblog_name}" offset="30" 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="{DATE_W3C}"}</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
{/exp:weblog:entries}
</urlset>
Placing the sitemap in your server’s root level
According to Google’s new sitemap rules, their sitemap tool does not accept URLs from a higher level or a different level. antbe, from the pMachine.com forums, posted a simple php workaround for this problem in this thread. The solution is the following (quoted from the original source):
EE doesn’t let you do this, but we can do that with a simple PHP script.
# Create a template, for example on /weblog/sitemap, like is explained on here
# The url of your sitemap will be http://www.example.com/index.php/weblog/sitemap/ or similar.
# Create a sitemap.php file and put it on your root path, the url of that file will be http://www.yoursite.com/sitemap.php
# The sitemap.php file must contain:
<?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.example.com/index.php/weblog/sitemap/');
?>
Now http://www.example.com/sitemap.php url is a clone of your template, use it on Google Sitemap.
For you fine folks on Dreamhost.com, since they don’t allow @readfile you may want to try this:
<?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
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.example.com/index.php/weblog/sitemap');
curl_exec($curl_handle);
curl_close($curl_handle);
?>
Adding entry specifc sitemap meta data
LG Better Meta (a commercial extension) allows you to add per entry sitemap meta data for the priority and change frequency attributes.
The sitemap meta data can be set using each entries weblog defaults or overridden in the publish/edit tab.
Fore more information about LG Better Meta and its sitemap generator checkout the documentation.
Category:Templates Category:SEO Category:Google
