3

We are working on an MVC web site where we are following the principles of atomic design, with heavy use of placeholders (including dynamic) and very granular renderings. This site's pages are heavily customizable using an approach similar to True Item Rendering.

We want to implement schema.org-inspired structured data for (Google) SEO, using the recommended JSON-LD format. You can find an introduction on Google's site.

Surprisingly, our authors want the same level of control over these data blocks as they have over displayed content. Unfortunately, I doubt you can insert a placeholder within a script tag, so flexibility is limited.

As an example, Google's sample for an article looks like this (abbreviated for clarity):

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "headline": "Article headline",
  "image": [
    "https://example.com/photos/1x1/photo.jpg",
    "https://example.com/photos/4x3/photo.jpg",
    "https://example.com/photos/16x9/photo.jpg"
   ],
  "author": {
    "@type": "Person",
    "name": "John Doe"
  },
  "publisher": {
    "@type": "Organization",
    "name": "Google",
    "logo": {
      "@type": "ImageObject",
      "url": "https://google.com/logo.jpg"
    }
  },
}
</script>

Complicating matters further is the fact that fields can accept various types of data -- for instance, author can be a Person or an Organization.

My current approach for this involves a main Article template, along with several link types for author, publisher, etc. These objects can in turn contain links to other objects. I fear this will become unmanageable in the long run, though it does make JSON serialization very easy using Glass Mapper.

I've considered the following solutions:

  • Allow authors to paste in the entire JSON block. I've seen that elsewhere, but I'd rather avoid it.
  • Have the renderings themselves register the data (either explicitly or by a rendering processor), then spit it out as JSON-LD at the bottom of the page. This solution curtails the flexibility our authors crave.

Are there any other approaches I should consider? Has anyone else come across this? Any OOTB solutions I should be aware of?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.