Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-10-24 13:50:47

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

JSON-LD instead of Microdata in default templates

We have a CS Glossary project in the early stages which will eventually become a collaborative content offer in the CSF site (main ToC landing page + definition articles). I think I’ve mentioned this before (I’ll look for the link)…

In relation to that, I was originally working on an RDFa spec for it, which, like Microdata, is an in-tags option for adding semantic structure, but can result in cleaner markup (fewer attributes overall and less referential URLs to schema.org) than Microdata if you scope semantic types across nested regions smartly.

But then I started talking about JSON-LD with some people who work in that area, and it became clear rather fast that for dynamically-generated sites, where markup is broken up and spread out across template files, that JSON-LD would be more sensible. It not only makes it easier to track and work on the semantic layer (in one place, instead of scattered throughout markup in any number of template files), but it cleans up the markup in those distributed partials too by removing the necessary schema attributes entirely.

The cleaner the markup, the easier it is to see and work with. On top of HTML attributes, Txp tags/attributes, and potentially ARIA attributes too, having at least the semantic attributes taken out is significant.

Seems to me it would be a good direction for Txp’s default templates too. It must have been considered, though. Any reason why you chose against?

Offline

#2 2016-10-24 17:04:41

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: JSON-LD instead of Microdata in default templates

Isn’t JSON-LD a way of describing data that is sent in JSON?

Offline

#3 2016-10-25 10:15:22

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: JSON-LD instead of Microdata in default templates

I don’t know much about JSON itself, but that’s not how JSON-LD has been introduced to me. Maybe it can do that too, but as I understand it, JSON-LD (now a W3C standard under the RDF working group), is another way to map content types to an ontology, or to a given schema. And just like with RDFa, or Microdata, the context can be with Dublin Core, Schema.org, FOAF… Or several at the same time.

Btw, “linked data” is just another way of saying “structured data”, which is equivalent to saying “structured content”.

The advantage with the -LD is that you manage it using JSON syntax in a single file — or, if convenient, in multiple files per different content types you may be working with. For example, I foresee that being better for CSF to have one -LD file for the glossary, one for CSF articles, and maybe a third for the rest of the general web content. But each file is a whole document, not broken up into markup tags across who knows how many partials. /gun to head/

I can easily imagine a new directory, /json-ld in the /assets directory next to /tempates.

Some resources and general things I’ve picked up so far:

  • JSON-LD 1.0 Rec
  • json-ld.org (has docs, playground, etc)
  • Wikipedia page on JSON-LD (short and simple)
  • Google uses it and recommends using it, for what that’s worth.
  • The relationship examples with other semantic formats
  • Code examples at the end of the Article schema page (not all that helpful, but shows that it does map a schema to HTML DOM)
  • SEO people prefer it.
  • In the short time JSON-LD has been around, adoption has grown quickly. Other semantic types, which have been around for a while, have seen slow adoption at best.
  • It’s a great choice as the web becomes more mobile and application-like.
  • It’s a great choice in terms of dynamic web development, such as CMS use, where markup is chunked apart. (One of my original points.)
  • It’s a great choice to clean up markup, which can otherwise be extremely loaded with attributes if one really wants to get serious about semantic structure. (One of my original points.)

Offline

#4 2016-10-25 11:10:21

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: JSON-LD instead of Microdata in default templates

I’m struggling to see how this works in a non-JSON environment (such as Textpattern) – can you provide a usage example? I’m not against using it if I can see a benefit over microdata attributes.

Offline

#5 2016-10-25 11:16:13

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: JSON-LD instead of Microdata in default templates

Maybe I first need to ask… what does a JSON environment look like? Are you suggesting there needs to be a JSON platform, or whatever, in order for a JSON-LD file to work?

Offline

#6 2016-10-25 11:28:20

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: JSON-LD instead of Microdata in default templates

Drupal uses JSON-LD, is that a JSON system? (I don’t know what a JSON system is, btw.). What about this WordPress + JSON-LD implementation?

Seems they are talking about some PHP file. Maybe that’s what your getting at? Seems possible, in any case.

I’m learning here too, of course. The semantic spec I originally wrote for CSF’s glossary was for RDFa, which I was then going to try and replicate in JSON-LD. But if there’s any issues about using it with Txp, now is a good time to realize them. ;)

Offline

#7 2016-10-25 12:41:19

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: JSON-LD instead of Microdata in default templates

I was saying that the core system doesn’t output content as JSON data as far as I know, and to me JSON-LD seems to be a way of describing that data in leu of having HTML. As I said, if an example can be provided of how that can be used to hook into parts of the HTML instead, negating the use of microdata then I’m up for trying to implement it.

Offline

#8 2016-10-26 07:41:35

springworks
Member
Registered: 2005-01-06
Posts: 172
Website

Re: JSON-LD instead of Microdata in default templates

Offline

#9 2017-01-31 10:52:30

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: JSON-LD instead of Microdata in default templates

I’ve opened an issue on the default theme repo to track this.

Offline

#10 2017-01-31 17:03:02

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: JSON-LD instead of Microdata in default templates

philwareham wrote #303753:

I’ve opened an issue on the default theme repo to track this.

I’m just posting here so as to return to this post. I find Phil’s investigations very interesting and want to learn from them.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#11 2017-02-07 11:38:20

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: JSON-LD instead of Microdata in default templates

Just as a side note, I’ve now added JSON-LD (along with other meta changes) to these forums and also the docs site. New .com site will also have some (limited) JSON-LD to compliment the microdata within its pages.

Offline

#12 2017-02-08 09:01:34

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,595
GitHub Twitter

Re: JSON-LD instead of Microdata in default templates

I starting to add JSON-LD into my personal (not finished yet) website.

This browsers extension could be useful for anyone wants to visualize and validate their snippets throughout their websites: http://osds.openlinksw.com/


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB