I personnay like when things show off a bit. Icons are this kind of things that are simple yet beautiful. This is way I wanted to add icons in front in the pages title, to make them more visible and catchy.
This one is just for demostration. As you can check there is also a dropdown menu which change depending on which page you’re:
Jekyll is awesome
The best of this icons is that they’re generated dinamically, there’s no hardcoding, all thanks to Jekyll.
For example, when I write a page and I want to add it an icon I just have to say where the icon is in the yml header
The tag img specify the relative path to the icon.
I also added an easy way to make a page visible in the dropdown menu
Here the group allow me to do the work. There’s also an icon as the variable img is set.
The Code
Now let’s see the code to get this working. I first changed the way the pages are listes. So I edited the file _includes/JB/pages_list:
I obviously changed the { and the { into < and > because otherwise it will be interpreted (there is a way to do it rigth but I was quite lazy, you can find it here).
The magic itself is done by the:
This piece of code is repeated many times. There’s also another include: JB/pages_dropdown Here is a fast view of the code:
Finnaly I have a page named projects.md
As you can see I use some variables, such as group and dropdown to make the magic. Then I just use Twitter Bootstrap to display a dropdown. In my own case I needed to change the css to make the colors fit my theme.