
pdoSitemap
Fast snippet for generating a sitemap for search engines (sitemap.xml). Accepts parameters from GoogleSitemap snippet (converts them to its own) and can replace it.
Main advantage is much higher speed compared to alternatives. On bezumkin.ru with 1700 pages, generation time dropped to 12x faster, from 8.4 sec to 0.7.
By default permission check for document access is disabled. You can enable it with the parameter &checkPermissions (Warning: slows execution!):
[[!pdoSitemap?
&checkPermissions=`list`
]]Prefer excluding resources from the map via snippet parameters.
Parameters
pdoSitemap accepts all pdoTools parameters and some of its own:
| Parameter | Default | Description |
|---|---|---|
| &sitemapSchema | <http://www.sitemaps.org/schemas/sitemap/0.9> | Sitemap schema. |
| &forceXML | 1 | Force output as XML. |
| &priorityTV | Extra field that stores priority of the document. Add it to the parameter &includeTVs |
Templates
@INLINE <url>\n\t
<loc>[[+url]]</loc>\n\t
<lastmod>[[+date]]</lastmod>\n\t
<changefreq>[[+update]]</changefreq>\n\t
<priority>[[+priority]]</priority>\n
</url>@INLINE <?xml version=\"1.0\" encoding=\"[[++modx_charset]]\"?>\n<urlset xmlns=\"[[+schema]]\">\n[[+output]]\n</urlset>Priority and update frequency for search engines are set from the document last-modified date:
| Time since last update | Priority | Update frequency |
|---|---|---|
| Less than a day ago | 1.0 | daily |
| More than a day, less than a week | 0.75 | weekly |
| More than a week, less than a month | 0.5 | weekly |
| More than a month ago | 0.25 | monthly |
How to create sitemap.xml
- Create a new document in the site root. On the Document tab choose an empty template, set any title, and alias sitemap. Ensure "Published" and "Hide from menu" are set as needed.
- Go to Settings and set "Content type" to "XML".
- Uncheck "Use HTML editor" and save.
- In the resource content, call only the pdoSitemap snippet (see Examples below).
Examples
Standard sitemap output for the current context. In most cases that is enough:
[[pdoSitemap]]Generate sitemap only from specific containers:
[[pdoSitemap?
&parents=`10`
]]Exclude resources with id 15 and 25, including their children:
[[pdoSitemap?
&parents=`10, -15,-25`
]]Exclude id 15 with children and 25 without:
[[pdoSitemap?
&resources=`-25`
&parents=`-15,10`
]]Add another context:
[[pdoSitemap?
&resources=`-25`
&parents=`-15,10`
&context=`web,catalog`
]]View the sitemap query log:
[[pdoSitemap?
&resources=`-25`
&parents=`-15,10`
&context=`web,catalog`
&showLog=`1`
&forceXML=`0`
]]