[MAGNOLIA-8378] Configurable way to end links with slash Created: 11/Apr/22 Updated: 24/Oct/23 |
|
| Status: | Open |
| Project: | Magnolia |
| Component/s: | core |
| Affects Version/s: | 6.2.17 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Richard Gange | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | seo | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Release notes required: |
Yes
|
||||
| Documentation update required: |
Yes
|
||||
| Team: | |||||
| Description |
|
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 The system is already capable of handling the ending slash. All of these links work:
Workaround
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. |