Remove wrong structured data from every subpage – add "Sitelinks Search Box" to the homepage only

AI-generated summary

The discussion revolves around removing incorrect structured data from subpages and implementing the “Sitelinks Search Box” only on the homepage. Currently, the code is implemented on every page, category, and topic, telling Google that each page is the website homepage ("url":"https://www.example.com/"), which is incorrect for subpages.

As per Google’s documentation, the “WebSite” structured data element should only be implemented on the homepage. rrit highlights this issue and suggests either removing the application/ld+json data from every page except the homepage or declaring the correct page-individual data for each subpage.

sam agrees that the feature only belongs on home pages and category/tag pages. rrit provides a PR (https://github.com/discourse/discourse/pull/16157) that removes the structured data from every page except the homepage.

The PR has been merged by nat, resolving the issue.

TL;DR: Right now we are telling Google for every page, subpage, topic, whatsoever that the page itself has "url":"https://www.example.com/"
– this is definitely wrong for a topic page with url like https://meta.discourse.org/t/add-sitelinks-search-box-to-the-homepage-only/219299


The Sitelinks Search Box’ code is implemented on every page, category and topic right now:

<script type="application/ld+json">
{
  "@context":"http://schema.org",
  "@type":"WebSite",
  "url":"https://www.example.com/",
  "potentialAction":{
    "@type":"SearchAction",
    "target":"https://www.example.com/search?q={search_term_string}",
    "query-input":"required name=search_term_string"
  }
}
</script>

E.g. see Google Search Console report ‘Enhancements’ → ‘Sitelinks searchbox’

As of Google it should be added to the homepage only:


https://github.com/discourse/discourse/pull/16157

2 Likes

Some more background on Googles: “Add [the search snippet application/ld+json data] markup only to the homepage, not to any other pages.”

This <script type='application/ld+json'> gives Google information on the content of the actual page/url it is defined on.

Right now we are telling Google for every page, subpage, topic, whatsoever that the page itself is:

  • "@type":"WebSite"
  • "url":"https://www.example.com/"
    – this is definitely wrong for a topic page with url https://meta.discourse.org/t/add-sitelinks-search-box-to-the-homepage-only/219299

Either we should remove the application/ld+json data from every page except of the homepage.
Or we should declare for every subpage the correct page-individual application/ld+json data representing the content of that page.

Examples on how to correctly use application/ld+json data for List-pages e.g. “Carousel”

3 Likes

Yeah, this feature only belongs on home pages and category/tag pages, pr welcome to improve

2 Likes

This PR DEV: output sitelinks search tag on homepage only by rr-it · Pull Request #16157 · discourse/discourse · GitHub removes the structured data from every page - except of the homepage. Homepage is the selected homepage: e.g. homepage, categorie-overview, topic-list…

My assumption is that there is no need for this structured data on category and tag pages.

1 Like

Hey there, thanks for your great PR – it is now merged.

2 Likes