Externalizing URLs for a sitemap

Avatar

Avatar

B_Stockwell

Avatar

B_Stockwell

B_Stockwell

16-03-2017

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?

View Entire Topic

Avatar

Avatar

Anton_Smulskiy

Avatar

Anton_Smulskiy

Anton_Smulskiy

16-03-2017

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