i need using _data in jekyll generate content.
let's want create directory displaying countries have blocked twitter , facebook. understand how query _data folder how create categories in _data .yml , query data?
let me try explain.
twitter blocked in turkey & iran i'd start (networks.yml in _data):
- network: twitter this stuck. don't understand if i'd want "tag" or "categorize" twitter this:
- network: twitter blockedcountries: [turkey, iran, iraq] - network: facebook blockedcountries: [iraq, turkey] then i'd want pages @ mysite.com/turkey/ display networks tagged turkey. this:
{% network in site.data.networks %} {% if network.blockedcountries == turkey %} <li>{{ network.network }} blocked in turkey</li> {% endif %} {% endfor %}` display: - twitter blocked in turkey - facebook blocked in turkey appreciate , tip bitcoin if solved!
your yaml right. problem seems in if statement:
{% if network.blockedcountries == turkey %} network.blockedcountries array(a list) , therefore if statement needs this:
{% if network.blockedcountries contains "turkey" %} <li>{{ network.network }} blocked in turkey</li> {% endif %} jekyll using liquid markup language templates. can read more possibilities here. maybe liquid case statement helpful further optimization.
here "full" solution:
my data in _data/networks.yml
- name: twitter blockedcountries: [turkey, iraq, iran] - name: facebook blockedcountries: [turkey, iraq] my liquid template in index.html
<ul> {% network in site.data.networks %} {% if network.blockedcountries contains "turkey" %} <li>{{ network.name }} blocked in turkey!</li> {% endif %} {% endfor %} </ul>
Comments
Post a Comment