XF 2.3 Where and how to add schema markup

80sDude

Well-known member
I looked around but couldn't find an answer to my question. How and where can I add a custom schema for my forum? Thanks!
 
It depends what you're trying to accomplish, but you can add it to a template via e.g.:

HTML:
<xf:page option="ldJsonHtml">
    <script type="application/ld+json">
       // your schema goes here
    </script>
</xf:page>
 
Thanks for the reply. Awhile I go I’m trying to added the code below structured data for the WebSite schema to the homepage of my forum to meet SEO standards and resolve structured data errors reported by SEMrush and Google. I ran a test with semrush and rich results test but they couldn't verify the schema which google flagged as well. Did I add that code in the right template and is that what I had needed to post? Thank you


Here’s the code I’m using:

Code:
<xf:page option="ldJsonHtml">
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebSite",
  "name": "example",
  "url": "https://www.example.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": {
      "@type": "EntryPoint",
      "urlTemplate": "https://www.example.com/search/search?keywords={search_keywords}"
    },
    "query-input": "required name=search_keywords"
  }
}
</script>
</xf:page>
 
XenForo already adds a similar schema out of the box if users have permission to search. You can edit the helper_js_global template to adjust it if you want.
 
Back
Top Bottom