How to Create an XML Sitemap in MODx

Creating an XML Sitemap in MODx

MODx offers site owners a variety of Extra (packages) that can be used to build an XML Sitemaps. Today we are going to use quickly create a sitemap using the extra named GoogleSiteMap written by YJ Tso and Garry Nutting. Configuring your sitemap should only take a few minutes.

Download MODx Extra: GoogleSiteMap

GoogleSiteMap MODx Extra
  1. Log into your manager account
  2. From the top navigation, select Extras Installer
  3. Click Download Extras
  4. Search for: "GoogleSiteMap"
  5. Download the package titled: GoogleSiteMap (authored by sepiariver)
  6. Click Back to Package Management
  7. Install the package
    Install GoogleSiteMap package
  8. The Details will appear, click Continue to start the install
  9. Confirm that no errors occurred during installation, then select Ok
Advertisements

Selecting the Best Version of GoogleSiteMap

Once GoogleSiteMap is installed, two Snippets can be called to build your sitemap.

  • GoogleSiteMap is the is the more modern and faster snippet. The downside of the faster load time is that some of the customizable properties are removed.
  • GoogleSiteMapVersion1 is the legacy snippet. It can take longer to load but it gives you the ability to narrow down the pages listed in the sitemap.

Building a XML File in MODx

A XML file is need to be created to house the sitemap. The process is very similar to creating a regular file, except you'll need to alter the template and content type.

  1. Create a new document off of the root directory
  2. Name your file (example: sitemap)
  3. Change the Template: (empty)
  4. In Settings, change Content Type: XML
  5. Save the file

Connecting GoogleSiteMap to a XML File

In our new XML file, simply call the snippet you would like to use. I like to call it uncached as the file will change as your site grows. To achieve this prepend an exclamation point '!' to the the snippet name. Once complete save your file and view it to confirm it is working.

[[!GoogleSiteMap]]
[[!GoogleSiteMapVersion1]]
Advertisements

Custom Properties

Custom properties can be used to narrow down the pages in your sitemap. You'll want to make sure you aren't submitting your 404-page, files behind a login wall, or other files you wouldn't want to be indexed. The properties for the sitemap can be found on the properties tab of the snippet.

Creating a Custom Property Set

When making changes to the default properties, it is recommended to create a custom property set. This ensures you always have a copy of the default properties on hand.

Custom Property Set
  1. Navigate to snippets. Elements Snippets GoogleSiteMap
  2. Select either GoogleSiteMap or GoogleSiteMapVersion1
  3. Select Properties
  4. Then Add Property Set
  5. Check "Create New Property Set"
  6. Name your property set and give it a brief description
  7. Click Save
  8. Select your property set in the dropdown next to "Add Property Set"
  9. {Make your updates to the properties}
  10. Select Save Property Set
  11. Finally select Save at the top

Calling Your Property Set

To attach the property set to your snippet, append an @ to the end of the snippet. Then directly after the @ enter the property name.

[[!GoogleSiteMap@MyPropertyName]]

Properties: GoogleSiteMap

Property Type Default
cacheExpires Textfield 86400
cachePartition Textfield googlesitemap
cachePrefix Textfield googlesitemap
containerTpl Textfield gContainer
context Textfield
googleSchema Textfield http://www.sitemaps.org/schemas/sitemap/0.9
hideDeleted Yes/No Yes
legacyProps Textfield allowedtemplates, excludeResources, excludeChildrenOf, sortByAlias, templateFilter, itemTpl, maxDepth, startId, where
legacySnippet Textfield GoogleSiteMapVersion1
priorityTV Textfield
published Yes/No Yes
searchable Yes/No Yes
showHidden Yes/No No
sortBy Textfield menuindex
sortDir Textfield ASC

Properties: GoogleSiteMapVersion1

Property Type Default
allowedtemplates Textfield
containerTpl Textfield gContainer
context Textfield
excludeChildrenOf Textfield
excludeResources Textfield
googleSchema Textfield http://www.sitemaps.org/schemas/sitemap/0.9
hideDeleted Yes/No Yes
itemTpl Textfield gItem
maxDepth Textfield 0
priorityTV Textfield
published Yes/No Yes
searchable Yes/No Yes
showHidden Yes/No No
sortBy Textfield menuindex
sortByAlias Textfield modResource
sortDir Textfield ASC
startId Textfield 0
templateFilter Textfield id
where Textfield
Advertisements