List of Jekyll tags per page

I am trying to display a list of tags using Jekyll. This is what my HTML looks like on the page:

<ul> {% for tags in page.tags %} <li>{{ tags }}</li> {% endfor %} </ul> 

And this is the information in my first question:

 --- layout: template title: Title tags: all portfolio something --- 

I get the output, but it just creates a list like this:

  • all portfolio something

instead of what I'm trying to achieve, here's what:

  • everything
  • portfolio
  • something

Any troubleshooting on this would be much appreciated, thanks!

+6
source share
2 answers

I tried on the new Jekyll website (with Jekyll 2.0.3), and the next front did well (be sure to use tags , not tag :

 --- layout: template title: Title tags: all portfolio something --- 

You can also use a list:

 --- layout: template title: Title tags: - all - portfolio - something --- 

Then use in your post or in your layout:

 <ul> {% for tags in page.tags %} <li>{{ tags }}</li> {% endfor %} </ul> 

If you still have a problem, consider updating Jekyll, providing MWE, or HTML / CSS output.

+10
source

For this front-end question :

 --- layout: template title: Title tags: all portfolio something --- 

You can assign page.tags | split:&nbsp; page.tags | split:&nbsp; in the variable used to iterate the for loop:

 {% assign tags = page.tags | split:&nbsp; %} <ul> {% for tag in tags %} <li>{{ tag }}</li> {% endfor %} </ul> 

It will output something like this:

 <ul> <li>all</li> <li>portfolio</li> <li>something</li> </ul> 
+1
source

Source: https://habr.com/ru/post/969621/


All Articles