logoalt Hacker News

lenkiteyesterday at 7:37 PM5 repliesview on HN

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.


Replies

_heimdallyesterday at 8:34 PM

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."

show 1 reply
klodolphyesterday at 7:54 PM

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 from the same data that I use to generate my site, and I use the JSON-LD metadata to generate things like index pages (list of blog posts from 2024, all posts related to topic X, etc). The main consumers of JSON-LD are search engines.

If you are interested in getting offended, then think about how we are also putting OpenGraph metadata in our web pages. Two different metadata formats for the same page.

show 1 reply
Dititoday at 7:30 AM

I don’t think you have understood the article enough. You can use Schema.org/FOAF/WikiData/etc. ontologies in HTML without JSON-LD and the script tags.

rglullisyesterday at 8:01 PM

What I see as the ideal would be a world where servers and browsers could do content negotitation, and have browsers attempting first to request only the json-ld from the website and using its own internal renderer format.

troupoyesterday at 8:49 PM

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".