-
Improvement
-
Resolution: Unresolved
-
Neutral
-
None
-
6.2.17
-
-
Empty show more show less
-
Yes
-
Yes
Frequently we are getting requests about how to generate links with a slash at the end rather than dot html or nothing at all. We need a configurable way to tell the system (LinkUtil) to generate links with a slash at the end. Mostly for SEO purposes.
The new configuration might make sense here /server/rendering/linkManagement/transformers.
endLinksWithSlash = true
Probably it would need to override any value that is configured here /server@defaultExtension
Another option would be to allow '/' to be an acceptable value for /server@defaultExtension
Notes
One of the issues we face is there is no easy way to override LinkUtil. It's not in the server config nor is it defined in a module descriptor.
The system is already capable of handling the ending slash. All of these links work:
- https://demopublic.magnolia-cms.com/travel/about.html
- https://demopublic.magnolia-cms.com/travel/about/
- https://demopublic.magnolia-cms.com/travel/about
Workaround
First, you will need remove the html value of /server/defaultExtension property (but this leaves the "." at the end of generated links).
So second, to be able to use just "/" as default extension you have to modify info.magnolia.cms.beans.config.URI2RepositoryMapping class and its getURI method. Like this:
public String getURI(Link uuidLink){ String uri = uuidLink.getHandle(); if (StringUtils.isNotEmpty(this.handlePrefix)) { uri = StringUtils.removeStart(uri, this.handlePrefix); } if (StringUtils.isNotEmpty(this.URIPrefix)) { uri = this.URIPrefix + "/" + uri; } String nodeDataName = uuidLink.getNodeDataName(); String fileName = uuidLink.getFileName(); String extension = uuidLink.getExtension(); if(StringUtils.isNotEmpty(nodeDataName)){ uri += "/" + nodeDataName; } if(StringUtils.isNotEmpty(fileName)){ uri += "/" + fileName; } if(StringUtils.isNotEmpty(uri) && StringUtils.isNotEmpty(extension) && !StringUtils.endsWith(uri, "/")){ - uri += "." + extension ; + uri += extension ; } return cleanHandle(uri); }
With that change in magnolia-core you will no longer get hardcoded "." before extension and (also google sitemap module) will use this new format with default configuration.
- is related to
-
MAGNOLIA-5886 New possible optional filter: Redirect Url's extension filter (SEO optimization)
- Accepted