Last updated Mar 7th, 2021 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
$292 per month—let's make that $500!Learn more
This snippet displays a Google Sitemap. Version 2 is many times faster than Version 1, but with less options. If params are specified that depend on the old version, it will be called. Check this page for the properties available in the old version.
Note: if you try to view a XML sitemap with tens of thousands of nodes in your browser, it will take a good long while to render it. However the server response should be a few seconds or less. More testing would be welcome. Please file issues here: https://github.com/modxcms/GoogleSiteMap/issues
Simply place the snippet in the Resource you want to use, and set the Resource's Template to 'blank':
Don't forget to set the content type to 'xml'.
|cachePrefix||A string prefix for cache file(s).||googlesitemap|
|cachePartition||Folder under core/cache/ for cache file(s).||googlesitemap|
|cacheExpires||Time to expire cache. Default is 1 day.||86400|
|legacyProps||Only modify this if you really know what you are doing. Properties in this comma-separated list will trigger the execution of the legacy GoogleSiteMap Snippet.||allowedtemplates, excludeResources, excludeChildrenOf, sortByAlias, templateFilter, itemTpl, startId, where|
|legacySnippet||Only modify this if you really know what you are doing. This snippet will be called if a legacy property is passed to the call to GoogleSiteMap.||GoogleSiteMapVersion1|
|containerTpl||The Chunk to use for the output container.||gContainer|
|context||Limit to the specified Context(s). If empty, will grab Resources from current Context. Defaults to empty, can support a comma-separated list.|
|googleSchema||The location of the GoogleSiteMap schema.||http://www.google.com/schemas/sitemap/0.9|
|hideDeleted||If true, will show only nondeleted Resources.||true|
|published||If true, will only show published resources.||true|
|searchable||If true, will only show searchable resources.||true|
|showHidden||If true, will include hidden Resources.||false|
|sortBy||The field to sort the results by.||menuindex|
|sortDir||The direction to sort in.||ASC|
There is 1 chunk processed with GoogleSiteMap:
- containerTpl - The Chunk to use for wrapping the results.
Display a sitemap for the current context:
Display a sitemap that combines both the web and marketing contexts:
Limit the sitemap to only the Resources with Template named 'BlogTemplate', and exclude the Resources with IDs 123 or 78:
[[!GoogleSiteMap? &allowedtemplates=`BlogTemplate` &templateFilter=`templatename` &excludeResources=`123,78` ]]
NOTE: the last example would call the legacy Snippet, which will time out if many thousands of nodes need to be generated.