How do I get pretty URLs?

I’m new to Hugo and ran into a hiccup regarding creating my site’s navigation.

Problem: My site’s urls all require /index.html at the end of the URL string. From what I’ve read in the docs, PrettyUrls should be enabled by default thereby preventing this kind of behavior (unless I’ve misread?).

Unfortunately, my repo is private. But my nav structure looks like this:

<ul>
    <li><a href="{{ "/index.html" | absURL }}">Foo</a></li>
    <li><a href="{{ "/bar/index.html" | absURL }}">Bar</a></li>
</ul>

Navigating to my site’s pages results in a URL that looks like this: www. mysite. com/index. html

I want the URL to read: www. mysite. com/

I’ve made no modifications to the site’s config and have attempted setting hugo -e HUGO_PRETTYURLS=true in my terminal to see if I can build something without the /index.html ending. I get the same results every time.

I should also note that I’ve played with different href values - omitting the “index.html” part. Doing that just results in a broken link on my site.

The nav example I provided is the only configuration I made that didn’t break my links.

1st
read the doc

don’t set the uglyurl value in config

2nd
I use href ="/" in my main menu

PS

my navigation template looks like

<li><a href={{ .URL }}>{{ .Name | markdownify }}</a></li>

1 Like

Unfortunately none of these recommendations worked.

I don’t have uglyurl set in my config. And after updating my nav template to match yours (and the menu docs for Hugo), I’m still seeing the index.html in my URL.

I’m afraid we’re going to need more details.

It’s cool. By setting the uglyurl to true, I’m a little closer to what I want.

For more context, my directory is set up as follows:

.
└── content
    └── events
        └── index.md  

Based on the examples in the docs, I expected the url to be something like https:// example .com/events/, but instead I’m getting https:// example .com/events/index.html

By setting uglyURLs = true, I now get https:// example .com/events.html - which is closer to what I wanted.

Thanks for your help on this, but I think I’m good.