
Crafting Structured Data for AI Responses
If you don’t know by now that AI is increasingly being used by the general public, I’d love to know what rock you’ve been living under.
With the increased usage of AI we started thinking, how can we ensure that the content you’re writing is being indexed by AI, and then presented back to people to provide them with accurate answers We’ve found a method to achieve this, so let's dive into the technical implementation and explain all of the nuances around this.
AI or Traditional Search
Why not both? If more people are using AI responses, such as the gemini summary built into google, it isn’t enough to just rank highly within the search results anymore. When an AI summary is present on the page, clickthrough rate falls drastically. Ranking highly is still important of course, but we also need to have an impact on those AI responses. To do this we need to affect those shorthand quick answers which we’ve seen for a while now displayed as collapsible questions and answers between results.
This isn’t a case of one or the other, the strategy must now include both AI and Traditional Search without being detrimental to one another.
How do we implement this?
Structured Data. Yes it really is that simple. You can do this on any website using any platform, our platform of choice is CraftCMS and we are using the SEOmatic plugin, this allows us to dynamically set structured data from anywhere within our templates based on the content entered in the CMS. We’ve created a specific FAQs block within our mixed content fields for this integration, this is available to most pages in the CMS and whenever you use one of these FAQ blocks, the structured data is populated alongside it automatically by the templates when displayed.
When the page is crawled, an FAQ block is detected in the structured data and each item has a question, and an answer, this is then used to populate the content within search engines. It also turns out that AI is very good at consuming these question and answer blocks. Instead of crawling the entire text on the page and reading through everything, AI uses this as a quick point of reference.
The best likeness I can give to this is when you are in a supermarket, the shop is essentially your website, each aisle is a webpage. Some aisles are poorly organised with no signposting and you have to look through every single product until you find the one you want, whereas others have defined sections so you can go straight to the relevant shelf and find it much quicker.
Implementing structured data helps AI index the high quality data it is looking for and allows it to cut through the rest of the noise. If somebody asks “What is the average lifespan of product x” and you have structured data implemented with an faq section answering that exact question, the AI will use your data over competitors, it may even provide a link through to your site for users to read more or purchase that product. If an AI chooses to use information from your competitor's site, you’ve potentially missed out on a sale.
Show me your code
So you want to see some code? Below you will find a simplified example where I have removed custom classes and any additional elements. This is a clean example of how to implement structured data for an faq block in your templates.
{% set entities = [] %}
{% for faq in faqs.all() %}
<div>
<h3>{{ faq.text }}</h3>
<p>{{ faq.textMultiline }}</p>
</div>
<hr/>
{% set entities = entities|merge([{
'type': 'Question',
'name': faq.text,
'acceptedAnswer': {
'type': 'Answer',
'text': faq.textMultiline
}
}]) %}
{% endfor %}
{% set faqJsonLd = seomatic.jsonLd.create({
'context': 'https://schema.org',
'type': 'FAQPage',
'mainEntity': entities,
'name': 'FAQs'
}) %}
In the above code example, we are looping through a collection of faqs entered by a user in the cms. When we output each question and answer combination, we are also building up a json array alongside it. After the loop is finished we then use this json array by passing it through to the seomatic plugin to generate our structured data.
If you are working with a different platform then you can output the structured data yourself following industry best practices, we have chosen to use a helper available to us though so it is all formatted correctly and being rendered at the correct point in our html structure.
The resulting output will look something like this:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "FAQPage",
"name": "FAQs",
"mainEntity": [
{
"@type": "Question",
"name": "How do I find you?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Check out our contact page!"
}
},
{
"@type": "Question",
"name": "Do I need to do anything?",
"acceptedAnswer": {
"@type": "Answer",
"text": "No."
}
}
]
}
]
}
</script>
Obviously you will have other elements alongside this within the structured data but I’ve stripped those out for the purpose of showing the relevant parts for our example scenario. We recommend that you then run the page url through a structured data validation tool to check it has all been rendered correctly.
Summary
AI uses Structured Data to help it contextualise and use your content more effectively, this essentially helps it to grasp the meaning of the page and improves the likelihood it will be used when forming a response. Implementing the above methods will also help with any traditional search engines as they validate and check these rich snippets and use them when building their results pages.
It makes sense to implement structured data using the content entered on the page as it provides benefits across the board, the implementation as seen above can be very simple but you can also evolve it into a much more complex offering depending on how much content you have and the goals of the given page.
In short, Structured Data really should be used more. If you’d like it added onto your website then please feel free to get in touch.

Matt Shearing
Matt develops custom plugins for Craft CMS to extend the core functionality. He also focusses on pagespeed improvements and server environments.