#Anakin
Member
Hi everyone,
I’m trying to fix some structured data issues reported by Google Search Console on my XenForo forum.
These are the main errors:
I added the following JSON-LD script at the end of the PAGE_CONTAINER template:
I'm aware that in newer versions of XenForo, it's no longer possible to directly edit templates like thread_view or post_macros, so I had to insert the script at the end of PAGE_CONTAINER, but that limits the available variables.
Questions:
Thanks in advance to anyone who can help clarify or suggest a cleaner solution. I’d really like to make the affected pages eligible for rich results again.
I’m trying to fix some structured data issues reported by Google Search Console on my XenForo forum.
These are the main errors:
- Missing field "url" (in "author")
- You must specify "text", "image", or "video"
I added the following JSON-LD script at the end of the PAGE_CONTAINER template:
Code:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"headline": "{$thread.title|escape('json')}",
"articleBody": "{$firstPost.message|strip_tags|escape('json')}",
"author": {
"@type": "Person",
"name": "{$firstPost.User.username|escape('json')}"
},
"datePublished": "{$thread.post_date|date('c')}",
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": "https://schema.org/CommentAction",
"userInteractionCount": {$thread.reply_count}
}
}
</script>
I'm aware that in newer versions of XenForo, it's no longer possible to directly edit templates like thread_view or post_macros, so I had to insert the script at the end of PAGE_CONTAINER, but that limits the available variables.
Questions:
- How can I correctly add the missing "url" field inside the "author" object (ideally pointing to the user’s profile)?
I was thinking something like:
"url": "{$link('members', $firstPost.User)|escape('json')}" — would that work? - Where should I specify "text", "image" or "video" to satisfy the second requirement?
- Is there a recommended way to manage structured data in XenForo when access to more specific templates is restricted?
Thanks in advance to anyone who can help clarify or suggest a cleaner solution. I’d really like to make the affected pages eligible for rich results again.