Closed rchaput closed 4 years ago
It's intended to use the hash ID of your first homepage widget for the home link as per the Demo - https://github.com/gcushen/hugo-academic/blob/master/exampleSite/config/_default/menus.toml . For example, use #about
if about.md
is your first widget, rather than /
.
The menu logic was developed in much earlier versions of Hugo so there is perhaps some more recent Hugo functionality that could be used to improve it.
Hello,
Describe the bug
When using sections in your menu (i.e. navbar), and when the current page is different that the Home page (
/
), two links are active in the navbar,/
and the current page (see the attached screenshot).To Reproduce
Steps to reproduce the behavior:
config/menus.toml
), such as:Home
), for exampleAbout Me
.Home
andAbout Me
links are active and shown as such (blue link andactive
class on the HTML element)Expected behavior
Only the current section should be marked as active, not the
Home
one as well.Technical details:
I believe I have tracked down the bug to the
navbar.html
partial (themes/academic/layouts/partials/navbar.html
), on line 84:If I am correct, this means that we check if
/
(theHome
URL) is in/aboutme/
(the current page relative permalink). This is true, so theactive
class is added. Replacingin
byeq
indeed solves this problem, but I imagine it brings a lot of other problems (such as not recognizing the hash with widget pages), hence I did not create a PR. I suppose we would need to first remove the (eventual) hash, and then compare the equality. Theis_same_page
part following this code would need to be modified as well, and I do not feel comfortable enough with the way Academic (or Hugo) works at the time present.