I have modelled a category page as a folder with a special file called “index” in it. The index file contains things like an title, introduction and metadata. Any other documents in the folder are rendered as the child pages of the category.
I have then added a sitemap entry using the index matcher:
This seems to work well but I have noticed that links to the category (i.e. the index file in a folder) come out as “/mycategory/index” rather than to “/mycategory/”. The page is served at both /mycategory/ and at “/mycategory/index”
How can I ensure that links are generated as “/mycategory/”? (Or is my approach to modelling categories wrong?)
Which version are you using? This might be related to:
We are using 13.3.0 so we should already have that bugfix?
I think you should model your sitemap different, as documented on this page:
If you use a index sitemap and set the relative content path to the index file. Then /mycategory/ links to the correct index file and the links will be correctly generated.
I have done some more investigation and the issue seems to be that If I add index under a default sitemap entry everything behaves as I want.
The issue is that I want arbitrary depth categories and so I have used an any sitemap entry with a child index. When i do this urls are generated with the /index. On reading the docs it does mention that index cannot be a child of any.
I am not sure if there is a way to support arbitrary depth categories? In reality there is a limit to the depth we would create but it would nice to have a compact sitemap.
_any_ always consumes the rest of the path, so it can never have children. This doesn’t mean you cannot have arbitrary depth categories, just not using this mechanism. You could have an index document on a url without referencing that document. The component that serves the request merely needs to know it has to retrieve a document called index on its relative content path.
If you combine the default sitemap with the index sitemap then you only need the any sitemap. Perhaps as fallback. I would only use the any sitemap for folders where no landing pages are needed.
Hope this helps.