Hi, I have a _index.bg in front matter which has links in it
[title](somepath/)
however the directory where _index.md is located has the same name “somepath”. This is intentional as I’m building country administrative structure where the region can have same name as a city. The problem is when generating the HTML, hugo converts the link to /basepath/somepath, instead of somepath/. This behaviour is only if the relative link path is the same as the current parent path part.
How can I force hugo to generate the proper relative url in the HTML ?
Could you clarify your question or provide live example to see behaviour.
Its likely that the way how links are generated are changed through render-link.html but that only assumption. Without more details it will be difficult to answer.
Ok, it appears @idarek is right, but just for the purpose of clarification I’ll explain further.
So I have the following structure on the website:
domain/
→ country/
----> region/
-------> city/
in the region/ folder, I have _index.md which contains relative markdown links to all cities in that region in the form of [city_name](city/)
If it happens the region name and the city name to be the same the HTML render of Hugo renders the relative links as /country/region, instead of /country/region/city, as it should be.
So I was able to solve the issue by overriding the render-link.html file with the following content: <a href="{{ .Destination | safeURL }}">{{ .Text | safeHTML }}</a>
I think the most correct way to do this would be to check in the template for city pages if the name of the current page equals the name of the region, then there will be JS code with a redirect to the region page or some other display. Or maybe I misunderstood something