Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery
SOLVED

Absolute URLs instead of relative URLs for XML Sitemap

Avatar

Level 1

Hello everyone,

 

Today, I checked our sitemap: https://www.elektro27.de/de/de.sitemap.xml

Unfortunately, AEM generates relative URLs, but we need absolute URLs.

 

RobinBl1_0-1716889990155.png

 

What are the possibilities to get absolute URLs?

 

Thank you for any help.

King regards

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @RobinBl1 

Have you reviewed the video on this page: Experience League that explains how to set up sitemaps at different paths? You can achieve this using AEM's out-of-the-box (OOTB) sitemap generator. Additionally, as outlined here: Sling Sitemap, you need to set sling:sitemapRoot = true for the /cards and /resources pages within the page properties.

Check the below ref for more info - Solved: How to create custom Sitemap url's on AEM 6.5 ? - Adobe Experience League Community - 667293

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @RobinBl1 
Which utility are you using to generate sitemap? OOTB, sling sitemap or custom implementation?

 

Arun Patidar

AEM LinksLinkedIn

Avatar

Correct answer by
Community Advisor

Hi @RobinBl1 

Have you reviewed the video on this page: Experience League that explains how to set up sitemaps at different paths? You can achieve this using AEM's out-of-the-box (OOTB) sitemap generator. Additionally, as outlined here: Sling Sitemap, you need to set sling:sitemapRoot = true for the /cards and /resources pages within the page properties.

Check the below ref for more info - Solved: How to create custom Sitemap url's on AEM 6.5 ? - Adobe Experience League Community - 667293

 

Avatar

Adobe Champion

For those coming to this thread looking for an answer that works when you dont have Sling Mappings on your site, you can override the default SitemapLinkExternalizer with the following `@Component` code (I apologize the forum formatting is lowercasing some of the annotations) to ensure the sitemap URLs get externalized.

 

import com.adobe.aem.wcm.seo.sitemap.externalizer.SitemapLinkExternalizer;
import com.day.cq.commons.Externalizer;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.settings.SlingSettingsService;
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ConfigurationPolicy;
import org.osgi.service.component.annotations.Reference;

/**
 * An implementation of {@link SitemapLinkExternalizer} that overrides the default implementation to
 * use the Sling Externalizer to generate fully qualified URLs for the sitemap.
 * <p>
 * Enable this component to generate fully qualified URLs in the sitemap when there are no sling mappings.
 */
@Component(
        property = {"service.ranking:Integer=" + Integer.MAX_VALUE},
        configurationPolicy = ConfigurationPolicy.REQUIRE,
        service = {SitemapLinkExternalizer.class}
)
public class SitemapLinkExternalizerImpl implements SitemapLinkExternalizer {
    @reference
    private Externalizer externalizer;

    @reference
    private SlingSettingsService slingSettingsService;

    @Override
    public @notnull String externalize(SlingHttpServletRequest request, String path) {
        return externalize(request.getResourceResolver(), path);
    }

    @Override
    public @notnull String externalize(Resource resource) {
        return externalize(resource.getResourceResolver(), resource.getPath());
    }

    @Override
    public @notnull String externalize(ResourceResolver resourceResolver, String path) {
        String mode = slingSettingsService.getRunModes().contains("author") ? "author" : "publish";
        return this.externalizer.externalLink(resourceResolver, mode, path);
    }
}