Broken ref to section/index.html with uglyurls

Dear all!
I think I stumbled across a minor bug:

I’m porting a hardcoded static html page to leverage some of Hugos features and get rid of duplicate markup.
I want to keep current urls for the first, thus using uglyurls = true

content organization is:

content/en/index.html
content/en/vision.html
content/en/product.html

This is exactly what I’d like to create in the end; e.g. http://baseurl/en/index.html
These sites also make up my main menu, thus they have menu=‘main’ in the frontmatter.

Now the issue:
though the file en/index.html is generated correctly, any .Ref to “en/index.html” converts into “en.html”.
Thus also the main menu contains a link to the section overview (list layout, which I do not use for now) “en.html” and not “en/index.html”.

I can fix this by reminding Hugo of the actual URL in the frontmatter of en/index.html:

url = ‘/en/index.html’

The following code generated links to en.html instead of en/index.html:

{{ .Ref “en/index.html” }}

and for the menu generation:

{{ $currentNode := . }}
{{ range .Site.Menus.main }}
<li {{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}>
	<a href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}

The ugly URLs are working as designed.

But, I think you’re going about this the wrong way. Putting an “index” file in your content folder doesn’t actually mean anything special to Hugo. It’s just the name of a piece on content. Your “index” files need to be dealt with in layouts, not in content.

Hey moorereason, thanks for your response.
I’m new to Hugo, so it might well be that I haven’t interpreteted that behaviour correctly.

an “index” file in your content folder doesn’t actually mean anything special to Hugo. It’s just the name of a piece on content.

Yes, and it’s also supposed to be a normal piece of content, just like vision,html and product,html.
The reason I created the file “content/en/index.html” is that in the page i’m porting there too exists the file at

mydomainname.com/en/index.html

And I’m using uglyurls, because I also want to keep the old addresses, e.g.

mydomainname.com/en/product.html
mydomainname.com/en/vision.html

What other way do I have to recreate that structure; to generate the file “en/index.html”?
I was thinking the homepage functionality using layouts/index.html only creates an index.html on root level, but not in a subdir; I would thus get “index.html”, not “en/index.html”

And to get back to my issue:

The ugly URLs are working as designed.

That would mean that by design with uglyurls (I repeat from above):

  • a page “content/foldername/index.html” renders to “foldername/index.html”, but any call “{{ .Ref “foldername/index.html” }}” does not return “foldername/index.html”, but “foldername.html”.

  • that means I cannot reference my file “foldername/index.html” using Ref or menu. (I havent checked any alternative for creating a ref)

Do you have more than one language on your site or do you just have english right now?

I see the problem you’re describing now. You’re really trying to mix pretty and ugly URLs. Look at Create a Multilingual Site.

Lots of good stuff with multilingual happening in the dev branch right now.

Right, the issue might be really specific to my use case.

We are a very new company and have started to build our website with multilanguage in mind; but right now there is only English.

Great to read that multilang is pushed forward! Excited to see this in 0.16!

Well, my fix to the problem still is putting url = “foldername/index.html” into the frontmatter so that refs deliver the right address.
We might as well close this thread if this is not a bug after all.

Best and thanks,
Dennis