0

I need to get some data using a dynamic name from front matter:

{{ site.data.prd-[page.tag].title" }}

The above fails to get the string from the data folder and nothing is output.

Where am I going wrong?

asked Apr 29, 2016 at 14:46

1 Answer 1

0

I am not sure about what you are trying to do but how about make a dictionary type data in _data directory and search for a title that matches page.tag in desired pages?

_data.prd-tags.yml

For each item, we can access the key and value using index ([0]: key, [1]: value).

jekyll: "jekyll's title"
ruby: "ruby's title"
html: "html's title"
.
.
.

HTML fragment for searching and displaying a tag (if found)

Iterate over site.data.prd-tags and display title if an item that matches page.tag is found.

<div class="tag-title">
 {% for tag in site.data.prd-tags %}
 {% if tag[0] == page.tag %}
 {{ tag[1] }}
 {% else %}
 Nothing found
 {% endif %}
 {% endfor %}
</div>
answered May 10, 2016 at 2:11
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.