SteveLane / hugo-icon

Icon theme for Hugo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add non-section link to nav?

colans opened this issue · comments

I'm trying to add a "Blog" link to the main nav so I can link to /blog, but I can't find any examples or documentation on how to add a link to the main nav that doesn't go to a section.

Is this possible? If so, how?

Thanks for the theme!

Hi, I haven't enabled any blog type feature, so you'd have to fiddle around with the pagination as well, unless you were just linking to a separate page?

To fiddle with menu items, you'd add a new entry to nav.html somewhere around here

This is not a huge priority for me at the moment, so I'd be saying good luck ;)

@SteveLane Yes, just a separate page.

What would the <a href... line look like, if you would be so kind?

I think you could just put a standard href in, e.g. <a href="link/to/my/blog/">my link text</a>

Certainly, the icon theme is very fine. However, I can not add a different section. I search for relations in all files, and adding a new section in the nav.html does not work. @maordano

Because there's js behind the scenes sending the page to the various sections on click events, you need to override that. Try the following in the line I link to above:

<a href="myurl.html" onclick="location.href='myurl.html';">Blog</a>

Thanks @SteveLane for the wuick response! I will try it! @maordano

@SteveLane Thanks! That seemed to work. Can it be added to the docs before we close this?

@colans
I try this within nav.html as:
{{ if .Site.Params.blog.enable }}
Blog{{ with .Site.Params.nav.blog }}{{ . | markdownify }}{{ end }}
{{ end }}

In the config.toml I add:
[params.nav]
blog ="Blog"
and their respective:

Blog section

[params.blog]
enable = true
title = "Blog"

This show a "Blog" label correctly in the main menu of the page.
However, when I pick "Blog", the message is: "Not found: ./blog.html"

Where you put the corresponding file blog.html? What is the correct location?

Many thanks
@maordano @nodoambiental

@nodoambiental Please see the new instructions in the README, merged above.