hcz-jekyll-blog icon indicating copy to clipboard operation
hcz-jekyll-blog copied to clipboard

current-menu-item style not applied when the url is set to an html file

Open GreatEmerald opened this issue 9 years ago • 4 comments

In my current setup, I have a menu like this:

urls:
    - text: Home
      url: /index.html
      icon: fa-home
      layout: post
    - text: Articles
      url: /category/General articles.html
      icon: fa-file-text
    - text: About
      url: /about/index.html
      icon: fa-user

(This is because the server I'm using at the moment only displays pages that really exist, so just a link to /about/ or / would give a 404.) This works fine, but the style of the menu button does not get the current-menu-item style applied to it when I visit the menu item.

GreatEmerald avatar Jul 13 '16 18:07 GreatEmerald

Which layout these .html files are using? Do they support/have YAML front matter in them?

codeasashu avatar Jul 13 '16 18:07 codeasashu

They're the same as the incuded sample files. The General Articles one is just an altered jekyll.md.

GreatEmerald avatar Jul 13 '16 18:07 GreatEmerald

Edit _config.yaml and look into urls (menus). It supports layout. Mention the layout your page is using and it will match with it and will highlight whenever the page is loaded.

So for ex- If your general articles.html has the this front matter:

===
layout: article
===

and you have a menu article in config, you can mention layout in the one you want to highlight. Please see how I am highlighting home menu whenever each blog individual page is visited. https://github.com/ashutosh2k12/hcz-jekyll-blog/blob/gh-pages/_config.yml#L13

and each post has the layout type post which matches the one with menu https://github.com/ashutosh2k12/hcz-jekyll-blog/blob/gh-pages/_posts/2016-06-04-example-content.md

If your HTML doesn't have front matter, it won't work. I will fix this in upcoming releases.

codeasashu avatar Jul 20 '16 06:07 codeasashu

Oh, OK. It does work that way, but then you have the problem that being inside a post always highlights "Home". So in my case, if I want to have a link to a listing of a particular category, the menu entry stays highlighted even if I go to a listing of another category. Hm.

GreatEmerald avatar Jul 26 '16 18:07 GreatEmerald