Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Externalizing URLs for a sitemap

B_Stockwell
Level 5
Level 5

I have a servlet on my page template at sitemap.xml.jsp that I'm using to generate a sitemap dynamically. I'm running into an issue with the display of the urls. 

The output currently displays like: 

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://dispatcher.localhost:8080/content/online/</loc> <lastmod>2017-03-15</lastmod> <priority>1</priority> </url> <url> <loc> http://dispatcher.localhost:8080/content/online/academics </loc> <lastmod>2017-02-23</lastmod> <priority>0.667</priority> </url> <url> <loc> http://dispatcher.localhost:8080/content/online/apply-today </loc> <lastmod>2017-02-24</lastmod> <priority>0.667</priority> </url> <url> <loc> http://dispatcher.localhost:8080/content/online/cincinnati-online-experience </loc> <lastmod>2017-01-02</lastmod> <priority>0.667</priority> </url> ...

As you can see in the <loc> element, instead of the domain (in this case http://online.uc.edu) it's showing a dispatcher url along with the /content/online 

A correct URL would be http://online.uc.edu/cincinnati-online-experience

I'm using externalizer.absoluteLink(), but that doesn't seem to be working in this case. Heres the relevent parts of my jsp file:

public Element getPageNode(Page page, Document doc, Externalizer externalizer, ResourceResolver resourceResolver, SlingHttpServletRequest request,int ogDepth) { //Create a result element Element url = doc.createElement( "url" ); Element loc = doc.createElement( "loc" ); loc.appendChild( doc.createTextNode( externalizer.absoluteLink(request, request.getScheme(),  page.getPath()))); url.appendChild( loc ); return url; }

Do I need to change a setting in the externalizer config to make the absolute link work?

1 Accepted Solution
daniel_henriqu1
Correct answer by
Level 4
Level 4

Hi, Ben.

Yes, there is a specific setting for Externalizer: http://<host>:<port>/system/console/configMgr/com.day.cq.commons.impl.ExternalizerImpl

You can configure a "domain" and use its name as the second parameter of externalLink call.

For further info, please check: https://docs.adobe.com/docs/en/aem/6-2/develop/platform/externalizer.html

Be aware that some Sling Mappings may also influence the links generated by the Externalizer.

Regards,

Daniel.

View solution in original post

0 Replies
daniel_henriqu1
Correct answer by
Level 4
Level 4

Hi, Ben.

Yes, there is a specific setting for Externalizer: http://<host>:<port>/system/console/configMgr/com.day.cq.commons.impl.ExternalizerImpl

You can configure a "domain" and use its name as the second parameter of externalLink call.

For further info, please check: https://docs.adobe.com/docs/en/aem/6-2/develop/platform/externalizer.html

Be aware that some Sling Mappings may also influence the links generated by the Externalizer.

Regards,

Daniel.

View solution in original post

Anton_Smulskiy
Level 3
Level 3

Try externalizer.externalLink(..). Make sure you have configuration for Externalizer domain

daniel_henriqu1
Level 4
Level 4

Or you can simply use Sling Mappings (reverse mapping) and ResourceResolver.map to achieve the same result.

Regards,

Daniel.