x
 
Create New Page

Revision: Google Sitemaps

Revision from: 10:02, 20 Nov 2006

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 RSS Page. You can change the values in red, see the Protocol for more info.

{assign_variable:master_weblog_name="weblog1"
{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="%Y-%m-&#xd;T;%H:%i:%s%Q"}{/exp:stats}</lastmod
<
changefreq><span style="color:red;">always</span></changefreq
<
priority><span style="color:red;">1.0</span></priority
</
url
{exp:weblog:entries weblog="{master_weblog_name}" limit="<span style="color:red;">500</span>" disable="categories|custom_fields|member_data|pagination|trackbacks" rdf="off" dynamic="off" status="Open"
<url
<
loc><span style="color:red;">{title_permalink="{template_group_name}/comments"}</span></loc
<
lastmod>{gmt_edit_date format='%Y-%m-&#xd;T;%H:%i:%s%Q'}</lastmod
<
changefreq><span style="color:red;">weekly</span></changefreq
<
priority><span style="color:red;">0.5</span></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="weblog1"
{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="%Y-%m-&#xd;T;%H:%i:%s%Q"}{/exp:stats}</lastmod
<
changefreq><span style="color:red;">always</span></changefreq
<
priority><span style="color:red;">1.0</span></priority
</
url
{exp:weblog:entries weblog="{master_weblog_name}" limit="<span style="color:red;">30</span>" disable="categories|custom_fields|member_data|pagination|trackbacks" rdf="off" dynamic="off" status="Open"
<url
<
loc><span style="color:red;">{title_permalink="{template_group_name}/comments"}</span></loc
<
lastmod>{gmt_edit_date format='%Y-%m-&#xd;T;%H:%i:%s%Q'}</lastmod
<
changefreq><span style="color:red;">weekly</span></changefreq
<
priority><span style="color:red;">0.8</span></priority
</
url
{/exp:weblog:entries} 
{exp
:weblog:entries weblog="{master_weblog_name}" offset="<span style="color:red;">30</span>" limit="<span style="color:red;">500</span>" disable="categories|custom_fields|member_data|pagination|trackbacks" rdf="off" dynamic="off" status="Open"
<url
<
loc><span style="color:red;">{title_permalink="{template_group_name}/comments"}</span></loc
<
lastmod>{gmt_edit_date format='%Y-%m-&#xd;T;%H:%i:%s%Q'}</lastmod
<
changefreq><span style="color:red;">monthly</span></changefreq
<
priority><span style="color:red;">0.5</span></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.yoursite.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.yoursite.com/index.php/weblog/sitemap/'
?> 


Now http://www.yoursite.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.yoursite.com/index.php/weblog/sitemap');
curl_exec($curl_handle) 
curl_close
($curl_handle); 
?> 

Category:Templates Category:SEO

Category:EE1

Categories: