Resolving incorrect or duplicate canonical and sitemap URLs from AEM domain and protocol configuration

AEM-generated canonical tags and sitemap URLs show the wrong domain, the wrong protocol, relative paths, or duplicate canonical tags when page properties, Externalizer, request headers, or template logic aren’t configured correctly. The most common causes are a missing Externalizer domain configuration, a missing X-Forwarded-Proto header, improper dispatcher clientheaders rules, or template logic that emits a second canonical tag. Correcting the page property and Externalizer settings, ensuring the protocol header reaches AEM, and removing duplicate template logic restores correct canonical and sitemap URLs.

Description description

Issue: AEM emits incorrect, duplicate, or relative canonical and sitemap URLs

Description

Sites in AEM display incorrect canonical URLs — http instead of https, relative URLs, or full URLs missing — or generate sitemaps that contain relative instead of absolute URLs. In some cases, AEM injects a default canonical tag when a custom implementation already generates one, producing duplicates. Misconfigured page properties, a missing Externalizer domain configuration, missing X-Forwarded-Proto headers, improper dispatcher clientheaders rules, or template-level logic that automatically emits canonical tags all trigger these symptoms.

Environment:

  • Adobe Experience Manager as a Cloud Service (AEMaaCS)
  • AEM Managed Services
  • AEM 6.5 on-premises
  • Dispatcher and CDN / load balancer tiers

Issue/Symptoms:

  • Canonical URLs appear as http:// instead of https://
  • Sitemap contains only slugs or relative URLs instead of absolute URLs
  • Duplicate canonical tags appear in the page source
  • The canonical tag auto-generated by AEM displays only a relative path instead of the full URL

Root cause:

AEM determines canonical and sitemap URLs from a combination of page properties, Externalizer configuration, request headers (especially X-Forwarded-Proto), resource resolver mappings, and template-specific logic. When any of these are missing, misconfigured, or overridden, AEM outputs incorrect, duplicate, or relative URLs. Some sitemap behaviors are also limitations in the Apache Sling Sitemap module.

How to confirm

  1. Match the observed symptom to one category: duplicate canonical tags, wrong protocol (http), missing domain, or a sitemap generating relative URLs.
  2. Inspect the page source and confirm how many canonical tags are present and whether each uses the correct protocol and domain.
  3. Fetch <site>.sitemap-index.xml in a browser and confirm whether the entries are absolute or relative URLs.

Resolution resolution

  1. Fix duplicate or incorrect canonical tags. Open Page Properties > Advanced and locate the canonical URL field, which controls automatic canonical generation. Clear or update the value as needed, then reload the page source and confirm only a single canonical tag remains. If the auto-generated tag still appears, check custom headerlibs or head.html for template logic that adds a second canonical tag, and remove or disable the duplicate logic.

  2. Fix canonical URLs that use the wrong protocol. Confirm your CDN or load balancer sends the header:

    code language-none
    X-Forwarded-Proto: https
    

Inspect the incoming request headers with browser DevTools or curl to verify the header is present. If it’s missing, update the CDN or load balancer rules.
3. For AEMaaCS, review the OSGi configuration deployed via Cloud Manager for org.apache.felix.http.sslfilter.SslFilter, with the following field values:

  • enable = true
  • forwarded = true
  • forwarded.header = X-Forwarded-Proto
  • forwarded.value = https

After deployment, view the page source to confirm canonical generation uses https.
4. Fix relative URLs or a missing domain in the sitemap. Confirm the sitemap-index.xml entry is being used — absolute URLs often appear only in sitemap-index.xml and not in the child sitemap.xml files. Then ensure your Externalizer domain configuration is deployed via code, using the com.day.cq.commons.impl.ExternalizerImpl-publish configuration. Add a simple test link using externalizer.externalLink or externalizer.publishLink to confirm the Externalizer produces absolute URLs.
5. Generate sitemaps using the AEM out-of-the-box capabilities. Confirm Generate Sitemap is enabled or disabled correctly on a per-page level. For pages marked as a sitemap root, AEM generates sitemap.xml and sitemap-index.xml. Access /content/<path>.sitemap-index.xml or /content/<path>.sitemap.xml directly to confirm the expected XML is produced. If the URLs return nothing, confirm the page is published. If you use Edge Delivery Services (EDS) sitemaps, note that lastmod and changefreq aren’t supported — this is a hard limitation, so don’t attempt to customize the EDS sitemap.
6. For MSM or multi-language sites on AEMaaCS, use the built-in Sling Sitemap with a page-level sling:sitemapRoot. The ACS Commons sitemap generator isn’t supported. Confirm sling:sitemapRoot = true is present on each language root, then access <langroot>.sitemap-index.xml to confirm each language root produces its own sitemap.

Validation

  1. Open the page source and confirm only one canonical tag exists, the protocol is correct, and the domain matches the expected configuration.
  2. Open sitemap-index.xml and sitemap.xml and verify absolute URLs appear where supported, with no relative slugs unless expected by Apache Sling Sitemap limitations.
  3. Confirm changes to the dispatcher, CDN, or OSGi configuration propagate after deployment. AEMaaCS applies these automatically on deploy.
recommendation-more-help
experience-cloud-kcs-help-kbarticles