Ask DN: Can anyone help me with my Jekyll site?

over 7 years ago from Adam Rasheed, Frontend Software Engineer

  • Oliver PattisonOliver Pattison, over 7 years ago (edited over 7 years ago )

    You probably want something like this:

    <ul> {% assign designers = site.data.designers %} {% for designer in designers %} <li><a href="{{ designer.src }}" target="_blank">{{ designer.name }}</a></li> <li><a href="{{ designer.src }}" target="_blank">{{ designer.name }}</a></li> <li><a href="{{ designer.src }}" target="_blank">{{ designer.name }}</a></li> {% endfor %} </ul>

    Why assign? You can only sort a for loop when it is assigned – so it’s good to get into that practice. If you wanted to sort a for loop by anything other than the exact order you’ve specified, assigning is the way to go.

    I’m not sure if that exact code will work on your site, but given a file called designers.yml in a _data folder in the root of your project, it should.

    0 points