Generating a "Google sitemap"
From phpCMS
[edit] Automatically generating a "Google sitemap"
To automatically generate a "Google sitemap" with phpCMS proceed as follows:
1. Write an additional menu template in the existing .mtpl file:
; Google sitemap (main menu level):
{GOOGLE.PRE}
{GOOGLE.NORMAL}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>1</priority>
</url>{MENU NAME="SUB1" MENTEMP="GOOGLESUB1" PARENTCLASS="{CLASS}"}
{GOOGLE.AKTIV}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>1</priority>
</url>{MENU NAME="SUB1" MENTEMP="GOOGLESUB1"}
{GOOGLE.PAST}
; Google sitemap (1st sub-menu level):
{GOOGLESUB1.PRE}
{GOOGLESUB1.NORMAL}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>0.8</priority>
</url>{MENU NAME="SUB2" MENTEMP="GOOGLESUB2" PARENTCLASS="{CLASS}"}
{GOOGLESUB1.AKTIV}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>0.8</priority>
</url>{MENU NAME="SUB2" MENTEMP="GOOGLESUB2"}
{GOOGLESUB1.PAST}
; Google sitemap (2nd (lowest) sub-menu level):
{GOOGLESUB2.PRE}
{GOOGLESUB2.NORMAL}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>0.4</priority>
</url>
{GOOGLESUB2.AKTIV}
<url>
<loc>http://domain.tld{LINK}</loc>
<priority>0.4</priority>
</url>
{GOOGLESUB2.PAST}
In the exmaple above
- "domain.tld" should be replaced by the domain name of the website to be submitted
- "SUB1" and "SUB2" should be replaced by the real names for the sub-menus
2. Create a new template file for the "Google sitemap" called "google_sitemap.tpl":
<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns="http://www.google.com/schemas/sitemap/0.84"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
{MENU NAME="MAIN" MENTEMP="GOOGLE"}
</urlset>
3. Create an Apache Rewrite Rule using .htaccess and mod_rewrite to wrap the /sitemap.xml call from Google to the parser:
# Rewrite Engine "on" RewriteEngine On RewriteBase / RewriteRule sitemap.xml /index.htm?template=/templates/google_sitemap.tpl
4. Calling the URL /sitemap.xml in a web browser, one should see in the source code a XML-formatted sitemap for Google.
Unfortunately one cannot define that phpCMS should deliver this file with the content-type of a XML-file, but apparently Google ignores such things, as sitemaps created like described above have already been accepted by Google.
Based on an entry by Martin Jahn in the phpCMS support forum
Main Page: Tutorials MainPage | Top Page: MiniHowTos MainPage
Diese Seite in anderen Sprachen: Deutsch

