2/27/11

Add a Google Sitemap

 
 
The Sitemap Protocol allows you to inform search engine crawlers about URLs on your Web sites that are available for crawling. The XML Sitemap Format provides a list of URLs and includes additional information about those URLs.
Create a Pagetemplate (Content-Type:text/xml) in your custom Folder. The Name should be something like sitemap.xml or google-sitemaps.xml (the .xml Extension seems to be required by google)
paste the code: 


------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
 <urlset xmlns="http://www.google.com/schemas/sitemap/0.84"
        xmlns:tal="http://xml.zope.org/namespaces/tal"
        xmlns:metal="http://xml.zope.org/namespaces/metal"
         tal:define="results python:container.portal_catalog(
                             portal_type = ['News Item','Document', 'Topic'], 
                             review_state=['published'],
                             sort_on='modified' ,sort_order='reverse');
                    dummy python:request.RESPONSE.setHeader('Content-Type', 'text/xml');
                    dummy2 python:request.RESPONSE.setHeader('charset', 'UTF-8');"
         tal:condition="results"
         tal:on-error="nothing" > 
  <url tal:repeat="result results" tal:on-error="nothing">       
            <loc tal:content="result/getURL">http://www.yoursite.com/</loc>
            <lastmod tal:content="python: DateTime(result.modified).HTML4()">2005-01-01</lastmod>       
   </url>
 </urlset>
into it.
This Pagetemplate list all your published contents of the types News Item,Document and Topic. Add all contenttypes or states you want to have listed in the sitemap.
If you are using EasyRating you may want to add a priority tag:
<priority tal:condition="result/amount_of_ratings | nothing" tal:content="python:result.average_rating/5">0.8</priority> 
assuming that your ratings are in a range between 0 and 5 (the default values). If you define other values you have to change the tal:content acordingly.
You can specify the location of the Sitemap using a robots.txt file. To do this, simply add the following line:
Sitemap: <sitemap_location>
The <sitemap_location> should be the complete URL to the Sitemap, such as: http://www.example.com/google-sitemaps.xml. This directive is independent of the user-agent line, so it doesn't matter where you place it in your file.
You can add your sitemap to Google Sitemaps at http://www.google.com/webmasters/sitemaps/

0 التعليقات:

Post a Comment

Related Posts Plugin for WordPress, Blogger...