Live data from Hacker News

JSON-LD explained for personal websites

hawksley.dev

11–20 of 94 posts

Re: JSON-LD explained for personal websites

#11
post #4

A bit disappointing that (IIUC) for the common parsers you have to say everything twice, in HTML and in the accompanying JSON-LD form even though RDFa exists for the exact purpose of letting you point at the values already present in your markup. (Admittedly RDFa is perhaps too flexible for its own good when you just want to mark up some stuff, but if you’re writing a full parser anyway dealing with a bit of excessiv…

And then there is https://schema.org/ It's the item* attributes, e.g.: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/... Also Dublin Core in tags. Why do they keep adding conflicting meta data formats to HTML!?!

I think if you are using Dublin Core, it’s because you’re a library. Maybe I am off the mark, but that is the sense I get from this—not all these standards should be used for all pages on the web.

I think you should just think about what metadata you actually care about, and the main metadata I care about (choose your own list) is authorship, publish date, last update, subject keywords, thumbnail (OpenGraph 1200x630), and summary.

There’s a long list of additional metadata that I could put in my webpages because there are standardized ways to do it, but, why bother?

Re: JSON-LD explained for personal websites

#12
post #6
post #3

We have semantic HTML, but for some weird reason we need to yet again re-express the semantic meaning of our website in bespoke weird JSON in a script tag that the browser won't process.

I have used JSON-LD in my own websites and found that it fills a separate need from semantic HTML. Your semantic HTML will specify things that the browser processes, like the title and headings. The JSON-LD data is metadata, like date created, date updated, tags, authorship. These things can be expressed in the HTML using micro data, but I stopped using micro data because JSON-LD was easier. The JSON-LD I populate fr…

Structured data exists yo pass the metadata. Issue with it is that of might impact the way your html needs to be structured, this can be messy.

Re: JSON-LD explained for personal websites

#14
post #4

A bit disappointing that (IIUC) for the common parsers you have to say everything twice, in HTML and in the accompanying JSON-LD form even though RDFa exists for the exact purpose of letting you point at the values already present in your markup. (Admittedly RDFa is perhaps too flexible for its own good when you just want to mark up some stuff, but if you’re writing a full parser anyway dealing with a bit of excessiv…

And then there is https://schema.org/ It's the item* attributes, e.g.: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/... Also Dublin Core in tags. Why do they keep adding conflicting meta data formats to HTML!?!

To be fair schema.org and dublin core say “when a property is name ‘title’ it means …” and you can expect to find the following properties…

Json-ld says: if you want to know whether the “title” property means the schema.org or the dublin core variant then you can find out which it is by

So you’d always use json-ld _with_ schema.org or something.

Re: JSON-LD explained for personal websites

#15
post #4

A bit disappointing that (IIUC) for the common parsers you have to say everything twice, in HTML and in the accompanying JSON-LD form even though RDFa exists for the exact purpose of letting you point at the values already present in your markup. (Admittedly RDFa is perhaps too flexible for its own good when you just want to mark up some stuff, but if you’re writing a full parser anyway dealing with a bit of excessiv…

And then there is https://schema.org/ It's the item* attributes, e.g.: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/... Also Dublin Core in tags. Why do they keep adding conflicting meta data formats to HTML!?!

They don't conflict; they were designed to work together. You can have schema.org (in JSON-LD, RDFa, or micro data) on the same page as Dublin Core, etc.

For example, there's no explicit property in schema's Person type [1] for a nickname. But the FOAF standard does [2].

Just add FOAF to the JSON-LD context:

    {
      "@context": {
        "@vocab": "https://schema.org/",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "pronouns": "https://schema.org/pronouns" 
    }


You now use the FOAF nickname property:

    "@type": "Person",
      "givenName": "Timothy",
      "familyName": "Berners-Lee",
      "foaf:nick": "TBL",
You can do the same thing with Dublin Core, DBPedia, etc.

[1]: https://schema.org/Person

[2]: https://xmlns.com/foaf/spec/#term_nick

Re: JSON-LD explained for personal websites

#16
I would encourage people who have the pragmatic bent to read about JSON-LD from the Google documentation for web sites;

https://developers.google.com/search/docs/appearance/structu...

You’ll also notice that a lot of the information is relevant to only a small subset of sites. Rotten Tomatoes can publish the critic rating for movies using JSON-LD, but that’s not relevant for me (even if I write a review for a movie).

JSON-LD is nice because it’s easy and it is actually used by search engines. Yes, it can duplicate information in the web page itself, but I think the dream of perfectly annotating information so it only appears exactly once in your document is, well, a dream of spherical cows and massless ropes. It takes human effort to make a webpage and I am ok with a little duplication in the final product. My duplicates information in anyway.

Re: JSON-LD explained for personal websites

#17

A bit disappointing that (IIUC) for the common parsers you have to say everything twice, in HTML and in the accompanying JSON-LD form even though RDFa exists for the exact purpose of letting you point at the values already present in your markup. (Admittedly RDFa is perhaps too flexible for its own good when you just want to mark up some stuff, but if you’re writing a full parser anyway dealing with a bit of excessiv…

IMO this is going overboard. Any time you are duplicating data from HTML into JSON-LD, consider just omitting that data from JSON-LD, unless the data isn’t consistently present in HTML (because it is a bitch to be consistent about this stuff). I tried using RDFa and liked the property that it was theoretically less redundant, but switched to JSON-LD because it JSON-LD is just easier to get working. And this is speaki…

> I tried using RDFa and liked the property that it was theoretically less redundant, but switched to JSON-LD because it JSON-LD is just easier to get working.

For me, it depends on the project. For personal projects, I tend to use RDFa; otherwise, JSON-LD.

Re: JSON-LD explained for personal websites

#18
post #3

We have semantic HTML, but for some weird reason we need to yet again re-express the semantic meaning of our website in bespoke weird JSON in a script tag that the browser won't process.

Microdata is also a thing, and if I'm not mistaken supports the same vocabulary as JSON-LD (schema.org is a good resource).

That said, JSON-LD has the default for a while now, much like how we largely abandoned REST for RPC. I'm not actually sure if microdata is still supported by all the important parsers today, I've defaulted to using LD for any site I've built for clients, especially ecommerce sites where I want Google Search exposure.

Edit: its worth noting the comparison with semantic HTML. Semantic HTML helps define the structure of the markup but not real world context like "this is a product for sale" or "this is a train schedule."

Re: JSON-LD explained for personal websites

#19
> It can aid web crawlers in understanding the semantic structure of your site, qualifying you for richer link previews, and even potentially improving your search ranking.

This is fighting the last war, to stretch a metaphor.

As far as I and my WWW site are concerned, Google has nowadays switched to giving people lengthy LLM-generated versions of my stuff, with errors, above pointing people to my actual stuff. 'Breadcrumbs' and getting a pretty display name instead of the domain name, don't address the fact that Google de-prioritizes all of that, pretty tweaks or no, nowadays.

This is a lot of effort for stuff that people visiting my actual site directly will never see, and which people using Google will not find above the fold of its own massively LLM-ized version of stuff.

Re: JSON-LD explained for personal websites

#20
post #3

We have semantic HTML, but for some weird reason we need to yet again re-express the semantic meaning of our website in bespoke weird JSON in a script tag that the browser won't process.

Semantic HTML doesn't cover what JSON-LD and other microformats cover.

From the article alone: what are the semantic elements for a person? A breadcrumb list? A software application? A blog? A blog posting?

Semantic HTML is there to aid humans using screen readers to navigate through generic elements like "navigation" or "article".

Post reply on HN