Link to index.md -> index.html

#1

I try to create a bunch of HTML files with relative links so that I can serve the files from a local directory without a server.
This works fine except for links to the main file called index.md.

This is my config.toml:

languageCode = "en-us"
title = "foo"
theme = "mytheme

relativeURLs = true
canonifyURLs = false
uglyURLs = true
permalinks = ":slug"
pygmentsCodeFences = true
pygmentsStyle = "manni"
pygmentsUseClasses = true

And I try to create a link like this:

{{<ref "index.md" >}}

where the index.md is in the contents directory. The file gets convertet to index.html, but the resulting link of the ref shortcode above is a link to a directory and not to index.html. What should I do to get Hugo to create a link to index.html? All other links look fine to me.

I am using Hugo v0.30.2

#2

I’d appreciate any help on this topic!

#3

Is the issue that visiting the site without a server isn’t showing the appropriate file for that directory? I am trying to understand the issue you are having. :slight_smile:

#4

Hi - please give us a link to your source. See hints here: Requesting Help
Thanks

#5

The repository with the source code is here:

https://github.com/pgundlach/hugoexample

See the files content/index.md and public/index.html. The result of {{< ref "index.md" >}} should be index.html and not /. When I try to read the resulting HTML files with a browser from my file system without a server, I cannot link to /.

#6

Hmm, the way you’re doing it is not so regular. Let’s start with a “normal” way of doing it. My site has a pretty typical setup.

http://live.cogley.info/index.html

See:


If you poke around in there you can see how things are linked together. The main layouts/index.html template uses .Content to pull from its companion content/_index.md.

It still does create the index.html in the root. I have not tried what you are trying, to get everything to work offline with relative links. It might be an option for you to simply publish it, then pull it down with wget and let wget convert it for local use. But it should also be possible to use the right combination of baseURL and relURL etc to get what you want.

#7

Hmm, the way you’re doing it is not so regular.

Can you tell me what is not regular? I don’t see anything wrong (= in contradiction to the documentation)

#8

Ok, looking at your stuff again, I see it’s just very sparse, but, should work. You’re right, there does not seem to be anything wrong. I though it was missing something because it’s sparse. But the structure seems ok.

As for rel returning a full index.html instead of /, I am not sure, but, maybe you could try “ugly urls”?

#9

Hello Rick,

thanks for your reply. uglyURLs is already set to true, Even setting it to false does not make any change.

Patrick

#10

Hmm. Just for testing, perhaps try quoting the value in your config? That is, doing "true" instead of true. TOML is supposed to support both, but, maybe try it for consistency.

#11

@RickCogley This doesn’t help either.

#12

I’ll try to ask a new question with a small correction I’ve got from another thread.

Link to index.md doesn't work