In the previous lesson you described each page of The Blue Cup with metadata: a title, a summary, an image for sharing. But a search engine reading the home page still sees, essentially, text. It reads "12 Example Street, Fictional Town" and has to guess that it's an address; it reads "10:00" in the workshop news item and has to deduce that it's the start time of an event. Structured data removes that guesswork: it's a standard way of saying, unambiguously, "this is a café, this is its address, these are its opening hours" or "this is an event that starts on 5 December at 10:00 and lasts three hours". With that information, search engines can display rich results: event dates, opening hours or business details directly on the results page. In this lesson you will get to know the schema.org vocabulary and the three ways of writing it (microdata, JSON-LD and RDFa), and you will mark up The Blue Cup's business details and its bread-making workshop.

Contents

  1. What structured data is
  2. Rich results: what you gain (and what isn't guaranteed)
  3. schema.org: a common vocabulary
  4. Three formats: microdata, JSON-LD and RDFa
  5. Microdata: itemscope, itemtype and itemprop
  6. JSON-LD: the data in a separate block
  7. The business: CafeOrCoffeeShop with address, phone number and opening hours
  8. An event: the bread-making workshop
  9. News: Article
  10. The menu: Menu and MenuItem (in passing)
  11. Testing tools
  12. Project: The Blue Cup's structured data

What structured data is

Structured data is information about the page's content written in a standard format with a shared vocabulary, so that any program can understand it without interpreting human language.

Compare how a program sees the same information:

Without structured data With structured data
Text: "Bread-making workshop… 5 December… 10:00… 3 hours… 12 Example Street" Type: Event. Name: "Bread-making workshop…". Start: 2026-12-05T10:00. End: 2026-12-05T13:00. Location: The Blue Cup, address 12 Example Street
The program has to deduce what each thing is The program knows what each thing is

You have already taken steps in this direction: the datetime attribute of time turns "20 October 2026" into 2026-10-20, and address indicates that a block contains contact details. Structured data takes that idea much further, with a vocabulary of hundreds of types and properties.

graph LR
    A["Visible content: text, tables, dates"] --> B["Structured data (schema.org)"]
    B --> C["Search engines: rich results"]
    B --> D["Voice assistants and maps"]
    B --> E["Other applications: calendars, aggregators"]

Rich results: what you gain (and what isn't guaranteed)

A rich result is a search result that shows more than the blue title and the description: the date and venue of an event, a recipe's star rating, expandable frequently asked questions, the price of a product…

Important points for keeping your expectations realistic:

  • Structured data makes a rich result possible, but doesn't guarantee it. The search engine decides when to show it.
  • Each search engine supports only some types for rich results, and changes them over time. Google, for example, publishes the list of types it uses in its developer documentation.
  • It isn't a trick for climbing the rankings: it helps the search engine understand the page and makes the result more attractive.
  • For a local business, the listing that appears on maps depends above all on the business profile that the owner registers with each search engine. The website's structured data complements it and reinforces consistency.
  • Golden rule: structured data must describe what is visible on the page. Marking up information the user can't see (an invented price, reviews that don't exist) goes against search engine guidelines and may lead to penalties.

schema.org: a common vocabulary

For every program to understand the same thing, a common vocabulary is needed. schema.org is a project created in 2011 by Google, Microsoft, Yahoo and Yandex that defines:

  • Types (with an initial capital): Event, Article, LocalBusiness, PostalAddress, Person…
  • Properties of each type (with an initial lower-case letter): an Event has name, startDate, endDate, location…

The types are organised in a hierarchy: each type inherits the properties of its parents.

graph TD
    T["Thing (name, description, url, image…)"] --> O["Organization"]
    T --> P["Place (address, geo…)"]
    O --> LB["LocalBusiness (openingHoursSpecification, priceRange…)"]
    P --> LB
    LB --> FE["FoodEstablishment (servesCuisine, hasMenu, acceptsReservations…)"]
    FE --> C["CafeOrCoffeeShop"]
    FE --> BK["Bakery"]
    T --> EV["Event (startDate, endDate, location…)"]
    T --> CW["CreativeWork"]
    CW --> AR["Article"]
  • CafeOrCoffeeShop is a FoodEstablishment, which is a LocalBusiness, which in turn is both an Organization and a Place. That's why a café can have address (from Place), telephone (from Organization) and servesCuisine (from FoodEstablishment) at the same time.
  • Always choose the most specific type that describes your case. The Blue Cup is also a bakery (Bakery), but its main activity is that of a café.

Each type has its reference page at https://schema.org/TypeName (for example, https://schema.org/Event), with all its properties. That address is also its identifier within structured data.

Three formats: microdata, JSON-LD and RDFa

The schema.org vocabulary can be written in three ways:

Microdata JSON-LD RDFa
Where it's written Attributes on the visible HTML elements A separate <script type="application/ld+json"> block Attributes on the visible HTML elements
Attributes or syntax itemscope, itemtype, itemprop JSON object with @context, @type vocab, typeof, property
Mixed with the content Yes: interwoven with the HTML No: separate Yes
Ease of maintenance Medium: a change in the HTML can break the markup High: everything in one place Medium
Google's current recommendation Supported Recommended Supported
Typical use Marking up existing content without duplicating it The default option today Sites with a semantic web tradition

In practice, JSON-LD is the recommended format today: it doesn't clutter the HTML, it's easy to read and maintain, and it can be generated by a program. Even so, you will learn microdata because it's pure HTML, because you will come across it on many sites and because it helps you understand the idea. RDFa is less common; it's enough for you to recognise it.

Microdata: itemscope, itemtype and itemprop

Microdata adds three attributes to elements that already exist on the page:

Attribute What it does Example
itemscope Declares that this element contains an "object" (an item) <article itemscope …>
itemtype Indicates the object's type, with its schema.org URL itemtype="https://schema.org/Article"
itemprop Indicates that this element's content is a property of the object <h2 itemprop="headline">

Let's look at a news item marked up with microdata:

<article id="autumn-coffee" itemscope itemtype="https://schema.org/Article">
  <header>
    <h2 itemprop="headline">Our autumn seasonal coffee has arrived</h2>
    <p>Published on <time itemprop="datePublished" datetime="2026-10-05">5 October 2026</time></p>
  </header>
  <p itemprop="description">This autumn we are serving a coffee from Finca El Mirador with notes of chestnut and cocoa.</p>
  <!-- rest of the news item -->
</article>
  1. itemscope on the article: "an object starts here".
  2. itemtype="https://schema.org/Article": "that object is an article".
  3. itemprop="headline" on the h2: the heading's text is the headline.
  4. itemprop="datePublished" on the time: this is the interesting part. For a time, the property's value isn't the visible text, but the datetime attribute. The search engine receives 2026-10-05.
  5. itemprop="description" on the paragraph: its text is the description.

Where does each itemprop take its value from? It depends on the element:

Element with itemprop Value taken
time The datetime attribute
a, link The href attribute
img, audio, video, iframe The src attribute
meta The content attribute
data The value attribute
Any other (p, span, h2…) The element's text

Objects within objects

A property can itself be another object. Just put itemprop and itemscope on the same element:

<div itemscope itemtype="https://schema.org/CafeOrCoffeeShop">
  <p itemprop="name">The Blue Cup</p>
  <p itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
    <span itemprop="streetAddress">12 Example Street</span>,
    <span itemprop="addressLocality">Fictional Town</span>
  </p>
  <p>Phone: <a itemprop="telephone" href="tel:+34900000000">+34&nbsp;900&nbsp;000&nbsp;000</a></p>
</div>
  • The address p is the café's address property and, at the same time, an object of type PostalAddress with its own properties.
  • The span elements (which you met in module 2) are useful here: they mark pieces of text without changing anything visually.
  • Be careful with the phone number: since it's on an a, the value would be the href (tel:+34900000000). Search engines understand it, but the cleanest approach would be to mark up a span with the text.

You can already see the main drawback of microdata: the markup is mixed with the content and makes it harder to read and maintain. If tomorrow someone changes that p to another element and deletes a span, the data disappears without anyone noticing.

Data that isn't visible: meta inside the body

Sometimes a property needs a value that doesn't appear as such in the text. In microdata you can use a meta with itemprop, even inside the body:

<meta itemprop="priceRange" content="€">

Use it sparingly, remembering the golden rule: what you mark up must correspond to what is visible.

JSON-LD: the data in a separate block

JSON-LD (JSON for Linked Data) writes the same data in an independent block, inside a special script element:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Our autumn seasonal coffee has arrived",
  "datePublished": "2026-10-05",
  "description": "This autumn we are serving a coffee from Finca El Mirador with notes of chestnut and cocoa."
}
</script>

Step-by-step explanation:

  1. <script type="application/ld+json">: the type tells the browser that this isn't executable JavaScript, but data. The browser neither runs it nor displays it; search engines read it.
  2. The braces { } delimit a JSON object: a list of "name": value pairs, separated by commas.
  3. "@context": "https://schema.org": the vocabulary being used. It's equivalent to the common part of the itemtype values.
  4. "@type": "Article": the object's type, like itemtype.
  5. The remaining lines are the properties, like the itemprop attributes, with their values in quotation marks.

JSON syntax rules you must follow (mistakes here are very common):

Rule Correct Incorrect
Names and text in straight double quotes "name": "The Blue Cup" 'name': 'The Blue Cup', “name”
A comma between pairs… "a": "1", "b": "2" "a": "1" "b": "2"
…but not after the last one "b": "2" } "b": "2", }
Numbers and true/false without quotes "maximumAttendeeCapacity": 15 (with quotes it is usually accepted too, but it isn't correct)
Lists in square brackets "dayOfWeek": ["Monday", "Tuesday"] "dayOfWeek": "Monday, Tuesday"
No comments — // comment

Where does the block go? It can go in the head or in the body; it makes no difference to search engines. A clear convention: data about the whole site or the page (the business) in the head, and data about a specific piece of content (an event, an article) next to that content.

The business: CafeOrCoffeeShop with address, phone number and opening hours

This is The Blue Cup's complete JSON-LD:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "CafeOrCoffeeShop",
  "@id": "https://thebluecup.example/#business",
  "name": "The Blue Cup",
  "description": "Neighbourhood café and bakery with speciality coffee, pastries and freshly baked sourdough bread every day.",
  "url": "https://thebluecup.example/",
  "logo": "https://thebluecup.example/img/logo.png",
  "image": "https://thebluecup.example/img/storefront.jpg",
  "telephone": "+34900000000",
  "email": "[email protected]",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "12 Example Street",
    "addressLocality": "Fictional Town",
    "addressCountry": "ES"
  },
  "openingHoursSpecification": [
    {
      "@type": "OpeningHoursSpecification",
      "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
      "opens": "08:00",
      "closes": "20:00"
    }
  ],
  "servesCuisine": ["Coffee", "Pastries", "Sourdough bread"],
  "priceRange": "€",
  "acceptsReservations": true,
  "hasMenu": "https://thebluecup.example/menu.html"
}
</script>

Property by property:

Property What it indicates Detail
@type Café The most specific type available
@id Unique identifier for this business An invented URL with #; it lets you refer to the business from other blocks (you will use it in the event)
name, description Name and description Consistent with the page text
url, logo, image Website, logo and photo Absolute URLs, as in Open Graph
telephone Phone number International format, as in the tel: href
address Address A nested object of type PostalAddress. addressCountry uses the two-letter country code (the business is in Spain: ES)
openingHoursSpecification Opening hours A list of time slots, each with days (full English names, as schema.org defines them), opening and closing times in HH:MM format
servesCuisine Type of offering List of text values
priceRange Price level The usual convention: from "€" to "€€€€"
acceptsReservations Does it accept bookings? true without quotes. It also accepts the URL of the booking form
hasMenu Menu URL of the menu page

If the opening hours varied by day, you would add more objects to the list. For example, if it closed at 14:00 on Sundays:

"openingHoursSpecification": [
  {
    "@type": "OpeningHoursSpecification",
    "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    "opens": "08:00",
    "closes": "20:00"
  },
  {
    "@type": "OpeningHoursSpecification",
    "dayOfWeek": "Sunday",
    "opens": "08:00",
    "closes": "14:00"
  }
]

An event: the bread-making workshop

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Event",
  "name": "Sourdough bread-making workshop for beginners",
  "description": "Learn to make your own sourdough bread with Carmen, our head baker.",
  "startDate": "2026-12-05T10:00+01:00",
  "endDate": "2026-12-05T13:00+01:00",
  "duration": "PT3H",
  "eventStatus": "https://schema.org/EventScheduled",
  "eventAttendanceMode": "https://schema.org/OfflineEventAttendanceMode",
  "location": {
    "@type": "Place",
    "name": "The Blue Cup",
    "address": {
      "@type": "PostalAddress",
      "streetAddress": "12 Example Street",
      "addressLocality": "Fictional Town",
      "addressCountry": "ES"
    }
  },
  "organizer": { "@id": "https://thebluecup.example/#business" },
  "maximumAttendeeCapacity": 15,
  "offers": {
    "@type": "Offer",
    "price": "25.00",
    "priceCurrency": "EUR",
    "availability": "https://schema.org/LimitedAvailability",
    "url": "https://thebluecup.example/bookings.html"
  }
}
</script>
  • startDate and endDate use the same ISO 8601 format as the datetime attribute of time (Other Semantic Elements). The time zone is added (+01:00, mainland Spain time in winter) so that there is no doubt.
  • duration uses the duration format you also know: PT3H, three hours.
  • eventStatus and eventAttendanceMode take predefined values (schema.org URLs): scheduled, and in person (not online).
  • location is a Place with its address.
  • organizer doesn't repeat the business details: with @id it refers to the object you defined on the home page. That way, the two blocks are connected.
  • offers describes the ticket: the price with a decimal point and the currency as an ISO code (EUR), the availability ("limited places") and the URL where you can book.

Remember the golden rule: the €25 price and the 15 places must also appear in the text of the news item.

News: Article

You have already seen how to mark up a news item with microdata. In JSON-LD, an Article usually includes:

{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "Bread-making workshop for beginners",
  "datePublished": "2026-10-20",
  "author": { "@type": "Organization", "name": "The Blue Cup" },
  "image": "https://thebluecup.example/img/share.jpg"
}

Search engines make use of Article mainly when each news item has its own page. In news.html, which is a list, it isn't essential, so in the project we will focus on the event, which is of direct interest to anyone searching for "bread-making workshop" in your town.

The menu: Menu and MenuItem (in passing)

schema.org also has types for restaurant menus: Menu, with sections (MenuSection) and dishes (MenuItem), each with its price (offers) and even its dietary restrictions (suitableForDiet). For example, one dish would be:

{
  "@type": "MenuItem",
  "name": "Butter croissant",
  "offers": { "@type": "Offer", "price": "2.40", "priceCurrency": "EUR" }
}

Marking up a complete menu is laborious and search engines barely use it for rich results today. For The Blue Cup, hasMenu pointing to menu.html, which you already included in the business, is enough.

Testing tools

Structured data isn't visible on the page, so a mistake can go unnoticed for months. There are two free tools for checking it:

Tool What it checks When to use it
Google's Rich Results Test Whether your data meets the requirements for Google's rich results, and which types it detects To find out whether Google will be able to use it
Schema Markup Validator (schema.org) Whether your data is correct according to schema.org, whatever the search engine To validate any type, including those Google doesn't use

Both let you paste the code directly, as well as analysing a published URL. As your site isn't on the Internet yet, use the paste-code option:

  1. Open the page with Live Server and copy all its source code (right-click > "View page source", select all and copy).
  2. In the tool, choose the Code option and paste.
  3. Review the errors (required data that is missing or incorrectly formatted) and the warnings (recommended data that is missing).

A warning doesn't stop the data from being valid; an error does. A JSON syntax error (a stray comma, a curly quote) causes the whole block to be ignored.

Project: The Blue Cup's structured data

  1. The business in index.html

Add the CafeOrCoffeeShop JSON-LD block from the previous section at the end of the head of index.html, after the social network metadata from the previous lesson:

    <!-- X (Twitter) -->
    <meta name="twitter:card" content="summary_large_image">

    <!-- Structured data: the business -->
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "CafeOrCoffeeShop",
      "@id": "https://thebluecup.example/#business",
      "name": "The Blue Cup"
    }
    </script>
  </head>

(Only the first properties are shown here so as not to repeat the block; copy the complete block from the section "The business".)

Check that everything you have marked up is visible on the page: the name, address, phone number and email are in the footer (address); the opening hours, in the #opening-hours section; the menu, linked from the home page.

  1. The event in news.html

In article#bread-workshop, make sure the visible text includes all the data you are going to mark up. Extend the paragraph about the next workshop that you already have so that it also includes the price and the maximum number of places (the 15 places already appeared in the booking conditions):

        <p>Next workshop: <time datetime="2026-12-05T10:00">Saturday 5 December, at 10:00</time>
          (length: <time datetime="PT3H">3 hours</time>). Price: €25 per person, materials included. Maximum 15 places.</p>

And at the end of the article (before it closes), the event's JSON-LD block:

      <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "Event",
        "name": "Sourdough bread-making workshop for beginners"
      }
      </script>
    </article>

(Again, copy the complete block from the section "An event: the bread-making workshop".)

  • The block is inside the article it refers to: whoever maintains the code will find it next to the news item.
  • organizer uses the @id of the business defined in index.html.
  • When the workshop has taken place and the next one is announced, the text and the JSON-LD will have to be updated at the same time. That's the price of having the data in two places.

  1. Checking

  1. Copy the source code of index.html and paste it into the schema.org validator: it should detect a CafeOrCoffeeShop with no errors.
  2. Do the same with news.html: it should detect an Event. Try it in Google's Rich Results Test too, which will recognise it as an event.
  3. Cause an error on purpose (add a comma after the last property), validate again and look at the message. Then fix it.

Common Mistakes and Tips

  • Marking up information that isn't visible on the page: it goes against the guidelines and may be penalised.
  • JSON syntax errors: trailing commas, single or curly quotes (“ ”), comments. A single error invalidates the whole block.
  • Writing the script without type="application/ld+json": the browser would try to run it as JavaScript and throw an error.
  • Relative URLs in url, image or logo: use absolute addresses.
  • Dates in a local format (05/12/2026): use ISO 8601, as in datetime.
  • Abbreviated days of the week or days in another language ("Mon", "Lunes"): schema.org defines them as full English names ("Monday").
  • Prices with a currency symbol or a thousands separator ("€2.40", "1,200.00"): use just the number with a decimal point, and the currency separately in priceCurrency.
  • Choosing a type that is too generic (Thing, Organization) when a specific one exists (CafeOrCoffeeShop).
  • Mixing microdata and JSON-LD for the same data: you could create two duplicate objects. Choose one format per object.
  • Expecting immediate rich results: the search engine decides when to show them, and it takes time to crawl the changes.
  • Tip: keep data in a single place where you can, and use @id to link it instead of copying it.

Exercises

Exercise 1. Find the five mistakes in this JSON-LD block:

<script>
{
  "@context": "https://schema.org",
  "@type": "Event",
  'name': "Seasonal coffee tasting",
  "startDate": "12/12/2026 18:00",
  "location": "The Blue Cup",
  "offers": { "@type": "Offer", "price": "€12.00", "priceCurrency": "EUR" },
}
</script>

Exercise 2. Mark up this fragment of The Blue Cup's footer with microdata (not JSON-LD) as a CafeOrCoffeeShop with name, address and phone number:

<footer>
  <p><strong>The Blue Cup</strong>, café and bakery</p>
  <address>
    12&nbsp;Example Street, Fictional Town<br>
    Phone: <a href="tel:+34900000000">+34&nbsp;900&nbsp;000&nbsp;000</a>
  </address>
</footer>

Exercise 3. The Blue Cup closes on 25 December and 1 January. Look up the validFrom and validThrough properties on schema.org's OpeningHoursSpecification page, and write the object you would need to add to the list of opening hours to indicate that it is closed on 25 December 2026. Hint: a closed day is expressed with opens and closes both equal to "00:00".

Solutions

Solution 1.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Event",
  "name": "Seasonal coffee tasting",
  "startDate": "2026-12-12T18:00+01:00",
  "location": {
    "@type": "Place",
    "name": "The Blue Cup",
    "address": "12 Example Street, Fictional Town"
  },
  "offers": { "@type": "Offer", "price": "12.00", "priceCurrency": "EUR" }
}
</script>
  1. type="application/ld+json" was missing from the script.
  2. 'name' used single quotes: JSON requires double quotes.
  3. The date didn't follow the ISO 8601 format.
  4. The price included the currency symbol: only the number goes in price.
  5. There was a stray comma after the last property.

In addition, location as plain text is acceptable for schema.org, but a Place with an address is more complete and is what search engines expect for events.

Solution 2.

<footer itemscope itemtype="https://schema.org/CafeOrCoffeeShop">
  <p><strong itemprop="name">The Blue Cup</strong>, café and bakery</p>
  <address>
    <span itemprop="address" itemscope itemtype="https://schema.org/PostalAddress"><span itemprop="streetAddress">12&nbsp;Example Street</span>, <span itemprop="addressLocality">Fictional Town</span></span><br>
    Phone: <a href="tel:+34900000000"><span itemprop="telephone">+34&nbsp;900&nbsp;000&nbsp;000</span></a>
  </address>
</footer>
  • The main object is declared on the footer, which contains all the data.
  • The name is taken from the text of the strong.
  • The address is a nested object (itemprop + itemscope) with two span elements for its parts.
  • The phone number is marked up on a span inside the link, so that the value is the text and not the href.
  • Notice how much more complicated the HTML gets. That's why, in the project, we use JSON-LD in the head and leave the footer clean. Don't also apply this markup to the project's footer: you would duplicate the business.

Solution 3.

{
  "@type": "OpeningHoursSpecification",
  "opens": "00:00",
  "closes": "00:00",
  "validFrom": "2026-12-25",
  "validThrough": "2026-12-25"
}
  • It is added as one more item in the openingHoursSpecification list, separated from the previous one by a comma.
  • validFrom and validThrough restrict the slot to that specific day; opens and closes at 00:00 indicate that it is closed.
  • 1 January 2027 would be added with another identical object. And, by the golden rule, the closure should also be announced on the page.

Conclusion

You have learnt that structured data describes the page's content with a common vocabulary, schema.org, so that search engines understand it without guessing and can display rich results, although there's never a guarantee that they will. You know the hierarchy of types and properties, and the three ways of writing them: microdata, with itemscope, itemtype and itemprop interwoven in the HTML; JSON-LD, in a separate script block, which is the recommended option today; and RDFa. You know how to describe a business with its address and opening hours, an event with its date, duration, location and price, and an article, and how to check it all with the Rich Results Test and the schema.org validator. The Blue Cup's home page now declares that it is a café with its address, phone number, opening hours and menu, and its bread-making workshop news item describes a complete event linked to the business. With this lesson you finish the module's topics on data and metadata; one last resource remains, which isn't about describing information but about drawing it. In the next lesson, Graphics in HTML: SVG and canvas, you will learn to create icons and vector graphics directly in the code and to draw with JavaScript, and you will turn the "Most ordered" list into a bar chart.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved