SteveLane / hugo-icon

Icon theme for Hugo
MIT License
87 stars 67 forks source link

How to add non-section link to nav? #24

Closed colans closed 5 years ago

colans commented 5 years ago

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!

SteveLane commented 5 years ago

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 ;)

colans commented 5 years ago

@SteveLane Yes, just a separate page.

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

SteveLane commented 5 years ago

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

nodoambiental commented 5 years ago

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

SteveLane commented 5 years ago

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>

nodoambiental commented 5 years ago

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

colans commented 5 years ago

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

SteveLane commented 5 years ago

Sure, do you want to add a note to the readme explaining what to do and then make a pull request?

On Wed., 6 Mar. 2019, 07:00 Colan Schwartz, notifications@github.com wrote:

@SteveLane https://github.com/SteveLane That seemed to work. Can it be added to the docs before we close this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SteveLane/hugo-icon/issues/24#issuecomment-469836128, or mute the thread https://github.com/notifications/unsubscribe-auth/AHFHjZtYmDx1HsZOndbhprVKRbqkCHFUks5vTszggaJpZM4bV4vX .

nodoambiental commented 5 years ago

@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

colans commented 5 years ago

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