Sitemap in xmCloud
This article includes a high-level overview of the sitemap in xmcloud and a few tips on how to manage and troubleshoot it.
Sitemap Configuration
The sitemap configuration can be found under the /Settings/Sitemap
. you can find the detailed field descriptions on the Sitecore documentation.
The sitemap media item will include the sitemap XML file and it will be automatically generated inside the /sitecore/media library/Project/[tenant]/[site]/Sitemaps/sitemap
. This media item will be assigned to the Sitemap media items
field of your Site
item.
Exclude a Page from the Sitemap
There are a few options to exclude a page from the sitemap, given your page template has an inheritance from:
- /sitecore/templates/Foundation/JSS Experience Accelerator/Multisite/Base Page
- /sitecore/templates/Foundation/Experience Accelerator/SiteMetadata/Sitemap/_Sitemap
You can set the Change frequency
field of the page item to do not include
.
This can be done on:
- Single page item
- On the branch template
- On the page template
If you have specific pages that should not be included in the Sitemap, you may want to consider using page branches
or specific page template
for those pages.
These are the sitemap filter pipelines:
<sitemap.filterItem patch:source="Sitecore.XA.Foundation.SiteMetadata.config">
<processortype="Sitecore.XA.Foundation.SiteMetadata.Pipelines.Sitemap.FilterItem.BaseTemplate, Sitecore.XA.Foundation.SiteMetadata"
resolve="true" />
<processor type="Sitecore.XA.Foundation.SiteMetadata.Pipelines.Sitemap.FilterItem.ChangeFrequency, Sitecore.XA.Foundation.SiteMetadata"
resolve="true" />
</sitemap.filterItem>
Sitemap generation process
The sitemap generation process will start after the publishing depending on the Refresh threshold
configured on the Sitemap setting.
For example, if your Refresh threshold
is 60 Minutes, and you have added a new page to the content tree, when you publish the page or site, the sitemap will not be updated. The next publish after 60 Minutes will update the sitemap.
If your authors will publish the pages 1 time per day you can set the Refresh threshold to Zero, so the sitemap will be updated after each publish.
If your authors publish frequently you may want to consider a higher refresh threshold and even some sort of automated scheduled publishing to update the sitemap.
High-level overview of the Sitemap generation process:
- The
Sitemap refresh [your site name]
job will start after the publish ended. - The sitemap media item will be deleted and a new sitemap media item with the generated sitemap XML will be added to the media library.
- The
Sitemap media items
field of yourSite
item will be updated with the newly created sitemap media item. - Two new publishes will be started (I am guessing here):
- One publish job will publish the media item:
/sitecore/media library/Project/[tenant]/[site]/Sitemaps/sitemap
- The second publish job will publish the site item:
/sitecore/content/tenant/site
- One publish job will publish the media item:
Link Provider for Sitemap
You can create a new link provider and use it for sitemap URL generation, you need to simply create the configuration:
<linkManager defaultProvider="switchableLinkProvider">
<providers>
<!-- In case you are using custom sitemap provider -->
<add name="mySitemapLinkProvider" type="Sitecore.XA.Foundation.Multisite.LinkManagers.LocalizableLinkProvider, Sitecore.XA.Foundation.Multisite"
lowercaseUrls="true" .../>
</providers>
</linkManager>
And on the Link provider name
field of sitemap configuration use the name of the provider: mySitemapLinkProvider
.
Diagnostics & Sitemap Query
If you are facing any issues with the sitemap, you can use the graphql query to check the sitemap item:
query SitemapQuery($siteName: String!) {
site {
siteInfo(site: $siteName) {
sitemap
}
}
}
This query should return the url of the media item for the sitemap. You may want to run the query against both xmCloud and Experience Edge.
Few places that you may want to check:
- Your Site item:
Sitemap media items
the field has a correct link. - Media Library:
/media library/Project/[tenant]/[site]/Sitemaps/sitemap
, check if exists, and check the statistics to see when it was updated last time. - Cache Type: if you set it to
inactive
on your sitemap configuration, the sitemap refresh job will still run but it will not do anything. - In case your sitemap media item is missing from the edge you can publish the media item.
- For testing purposes, you can delete the sitemap media item, set the
Refresh threshold
to Zero, and publish the site, the sitemap refresh job should create a new media item and assign it to the site item. - If you have an issue with rendering of the sitemap in front-end you may want to check
pages\api\sitemap.ts
in your nextjs app.