.Root.Site.Home.Permalink
with uglyurls = true
is not so ugly.
For content/post/_index.md
, its permalink ends with post.html
On the other hand.Root.Site.Home.Permalink
looks like ../..
.( does not end with index.html
)
Some themes, such as hugo-geekdoc
, use .Root.Site.Home.Permalink
in the layout to navigate to the root page.
However with file:
access, .Root.Site.Home.Permalink
links to directory listing, not a root page.
Is there a good way to get an ‘ugly’ link to the root page?
This is a known issue:
https://github.com/gohugoio/hugo/issues/7497
For anyone stumbling across this, Root
is not a method on anything. It’s a construct of the hugo-geekdoc theme:
{{ partial "site-header" (dict "Root" . "MenuEnabled" $navEnabled) }}
Capitalizing the first letter isn’t a great idea.
I see this is duplicated and still open issue.
As a workaround, hope to add ’index.html’ when in uglyurls = true
.
Is there a way to implement `some_good_predicate_to_check_uglyurl?
href="{{ .Root.Site.Home.Permalink }}
{{ if some_good_predicate_to_check_uglyurl }}/index,html{{end}}
">
Unless you will always publish another page that you could check, the answer is no. And even if you could check another page, that may not be indicative of intent because uglyURLs
can also be configured per-section.
For anyone stumbling across this, these two issues are closely related:
Addressing the first one would break some existing sites. So this is either a V2 thing or a reallyUglyURLs
config setting. But then we also have ugly
and noUgly
properties for each output format, so we’d have to decide how those should behave. It’s messy.