DevHub Docs
Search…
Schema.org FAQ utility
Connect your template data to generate FAQ schema on a page
Example Schema.org structure that it generated

Basic usage example

faq_items in this example is hard-coded. But you would replace with your own data fields.
1
{% set faq_items = [
2
{
3
'answer_text': 'Answer to question 1',
4
'question_name': 'Question 1?'
5
},
6
{
7
'answer_text': 'Answer to question 2',
8
'question_name': 'Question 2?'
9
}
10
] %}
11
12
<script type="application/ld+json">
13
{{ faq_items|as_faq_schema|tojson|safe }}
14
</script>
Copied!

Using custom field data example

Looping over some custom field values to generate the FAQ items.
1
{% set faq_items = [] %}
2
{% for i in range(1, 5) %}
3
{% set title_value_key = 'faq_title_text_%s' % i %}
4
{% set description_value_key = 'faq_description_text_%s' % i %}
5
{% if site.custom_fields[title_value_key] %}
6
{% do faq_items.append({
7
'question_name': site.custom_fields[title_value_key],
8
'answer_text': site.custom_fields[description_value_key]
9
}) %}
10
{% endif %}
11
{% endfor %}
12
13
<script type="application/ld+json">
14
{{ faq_items|as_faq_schema|tojson|safe }}
15
</script>
Copied!
Last modified 9mo ago