You are here: Services / Web / TYPO3 / mc_googlesitemap Multi-Language
English
Deutsch
¬Social Bookmarks 
digg.comFurlgoogle.comstumbleupon.com

The TYPO3 extension mc_googlesitemap is very helpful for creating XML-coded sitemaps which are used by Google etc. Unfortunatelly mc_googlesitemap does not really take care about sites having multiple languages. The extension could either be patched for this purpose or a special setup with several Sitemaps can be used. This article shows how to configure your site with a special setup. It relates to the mc_googlesitemap version 0.4.2.

The TYPO3 extension realurl is assumed to be configured.

Sitemap Index

Instead of directly listing pages a Sitemap may actually hold a Sitemap Index which refers to other Sitemaps which are finally listing the pages.

Create a page with a single content element Sitemap of type Sitemap with the menu type Google Sitemap Index. This page is the one to present to the search engines.

Sitemap for Pages

TYPO3 pages holding content elements of type sitemap with the selection 'Google Sitemap For Pages' list the pages of the current language only. Current does not mean the one set by

config.sys_language_uid = 2

It means the language the page is called for, the language is usually coded in the Get-parameter 'L' located in the url

Defining

config.linkVars=L2

for the second language does not work neither, by the way.

To get around this we need two sitemaps listing pages, one for the default language and another one for the special languages, e.g. German which is coded as a 2 in this example.

Wrong Way

Create a single page with one content element of type Sitemap for Pages, translate the page holding another Sitemap for Pages we have the two maps in one page. Depending on the language the page is called with, we see either an XML coded list of pages for the default or the other language.

However the Sitemap Index shows the address of this page without applying the different languages, neither by adding 'L' as a query string nor by using real-url translated URLs.

So we cannot proceed this way.

Sitemaps on different pages

To cope with this, the sitemaps are created on different pages. One for the default page, one for German.

Now the sitemap-index shows the differing URLs of both of them. Unfortunatelly the language code is not included in the URLs.

Trying to patch this by adding a Typoscript for the special sitemap adding

config.linkVars=L2

does not help since this would affect just the links built on this page. It does not add the parameter to the URL of the page, thus, mc_googlesitemap will not see it.

Realurl, htaccess

To get around this we use htaccess internally redirecting the German Sitemap to the Sitemap-path including the language code. To avoid retranslating the urls of the pages by some extension we switch of realurl for the page holding the Sitemap Index

config.tx_realurl_enable = 0

Do not forget to re-enable realurl for the pages with the actual Sitemaps in case they are located below the page with the Sitemap Index.

htaccess should redirect the non-default Sitemap

RewriteCond %{QUERY_STRING} id=894
RewriteRule ^index.php$ index.php?id=894&L=2 [L]

internally adding the language parameter for the page which generates the sitemap for e. g. German. Adapt the 2 according to your language code.

Multiple Sites

Maybe you have a TYPO3 installation with multiple sites. Linking between pages using fully qualified links is no problem as long as

config.typolinkEnableLinksAcrossDomains = 1

is defined in the template. Unfortunatelly, mc_googlesitemap has problems with this parameter. Instead of e.g. showing

<url>
  <loc>www.i2c-bus.org/de/i2c-bus/</loc> 
  <lastmod>2009-05-19T12:25:36Z</lastmod>
</url>

you will get something like

<url>
  <loc>www.i2c-bus.orghttp://www.i2c-bus.org/de/i2c-bus/</loc> 
  <lastmod>2009-05-19T12:25:36Z</lastmod> 
  </url>
<url>

To fix this, simple reset the parameter in the typoscript template for the Sitemap:

config.typolinkEnableLinksAcrossDomains = 0

Problems?

In case you still have problems, you may consider to

  • clear the page- and realurl cache
  • manually call the language specific sitemap pages including the L parameter and check to get the pages you expect

Finally

Finally we should have a Sitemap with a Sitemap Index addressing to two Sitemaps, one presenting the default language pages, one list the second language pages. More languages are possible of course.

In case of problems please address ok03(at)telos(dot)de

 

 

Wenn Sie diesen beiden Bücher haben und nutzen, kann Ihnen kaum etwas passieren:

TYPO3 Kochbuch
Eine Buch voller wertvoller Details; keines, dass Ihnen Schritt für Schritt den Weg zeigt.

 

TYPO3 und TypoScript - Kochbuch. Lösungen für die TYPO3-Programmierung mit TypoScript und PHP  

Im Mai 09 erschien diese neue Auflage des Klassikers.

 

Beide Bücher sind nicht für die ersten Schritte mit TYPO3 empfehlen, sie richten sich eher an Personen, die schon etwas Erfahrungen mit dem Framework haben.

 
www.telos.de