Structured Data (Schema) for Xenforo

Sitebee

Technical SEO
Staff member
Below is how I crafted the schema breadcrumbs path and the WebPage schema for Xenforo 2. Add this to the head section of your PAGE_CONTAINER template file. This works great for Xenforo pages, for some reason the developers left out structured data for pages.

JSON snippet for breadcrumbs
Code:
<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "BreadcrumbList",
  "itemListElement": [{
    "@type": "ListItem",
    "position": 1,
    "name": "Home",
    "item": "{{ link('canonical:index')|escape('js') }}"
  },{
    "@type": "ListItem",
    "position": 2,
    "name": "{$h1}",
    "item": "{$xf.fullUri}"
  }]
}
</script>

JSON snippet for WebPage schema
Code:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebPage",
"name": "{$h1}",
"description": "{$description}",
"publisher": {
"@type": "WebPage",
"name": "{'boardTitle': $xf.options.boardTitle})|escape('js') }}"
}
}
</script>


I've also used this for the meta description tag. If you decide to implement this, then I recommend you duplicate your theme xml file, rename it and remove the description tag from within the PAGE_CONTAINER template file.
Code:
    <meta name="description" content="{$description}"/>

For the canonical tag, I used this Xenforo conditional
Code:
<link rel="canonical" href="{$xf.fullUri}" />

If you need a helping hand, comment below. I will do my best to help you out. If you need support SEO optimising your Xenforo community, reach out to me. I'm available to hire on a hourly freelance basis.
 
Last edited: