gohugoio/hugo

Links to external sites as menu entries

Closed this issue · 16 comments

Hi,

I was wondering if there is an intuitive way to add external links to our project's hugo site. It shows a menu in the header, and I can extend the menu by adding an entry to the config.toml of our site, like in this example (as described in https://gohugo.io/extras/menus/):

[[menu.main]]
name = "GitHub"
weight = 0
identifier = "GitHub"
url = "http://github.com/petschau/WinFellow"

What happens is that the URL is added to the menu just fine, but it has a "index.html" attached to it, which breaks it. The documentation says that the URL must be relative to the context root (so I suppose this is intended for links pointing to the hugo site only).

Is there any other way to define this so that an external URL can be followed, without having to edit the header template file?

bep commented

The above should just work, and is a bug if not. What is the output of hugo version?

Thanks for confirming that it should work, as the documentation had me wondering if it's correct.

Hugo Static Site Generator v0.15 BuildDate: 2015-11-25T14:35:20+01:00

is the output of the command. I use the 64 bit windows binary; I just tested it again, it happens both in a local preview using hugo server, as well as when performing the actual compilation by executing hugo.

Do you need any other information? I have checked the complete hugo configuration we use into a separate branch here, as it will be helpful if other team members should ever have to prepare a website update.

I really appreciate how easy and straightforward hugo makes this, as everyone with a basic understanding of MarkDown can prepare website changes with little effort, once the configuration is set up properly. Thanks for the work you are putting into hugo!

bep commented

Just tested this, and it works fine in the latest Hugo.

I suspect this was fixed in d35d820 -- which means you would have to either use the latest dev version or wait for a new release.

bep commented

Or, it should have worked before that commit, too .. I'll create a test case for it to see if it breaks on Windows...

I've tested this on Windows using the latest build (build Hugo Static Site Generator v0.16-DEV BuildDate: 2016-01-14T04:02:32+01:00). I produced the build myself, there are no nightly builds available, are there?

The issue still exists in that build, you can see the broken URL in the bottom left corner of this screenshot:

2016-01-14 04_33_05-winfellow - amiga emulator for windows

bep commented

Cannot reproduce, so must be something else. Is your Hugo source online somewhere?

Yes, our hugo source data is on GitHub here, though it is the one that's currently live, without the adapted config with the additional menu item. I've pasted the snippet from my first post to the end of config.toml to add that menu item.

None of my PCs have an OS besides Windows, so testing it myself wouldn't be easy for me. Thanks for looking into it!

bep commented

I'm not even finding config.toml in that site you posted ...

It's directly in the root folder? The direct link should be https://github.com/petschau/WinFellow/blob/hugo/config.toml, are you able to open that?

bep commented

Ah, I see ... it was in a branch.

Yes, I just used our existing project repository and put both the config into it (branch hugo), as well as the output files to the usual gh-pages branch. I think that's most convenient to have it available for the other team members. The page is not updated frequently, so switching the branch to perform an update is not a huge deal. I may still look into automating that process though.

bep commented

Have a look in the header.html template:

{{ range .Site.Menus.main }}
    <li class="page_item"> 
        <a href="{{ .URL }}index.html">{{ .Name }}</a>
    </li>
{{ end }}

Ouch, so it's actually an error in the theme? Thanks for pointing that out, and sorry for the effort I caused you!

bep commented

Ouch, so it's actually an error in the theme?

Yes.

Looks good after I removed that. It's odd, as I just did minor modifications to an existing theme because I'm not familiar enough with it yet to build my own. Once I have my updates done, guess I should report that back. Thanks again for your help!

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.