npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nera-static/plugin-structured-data

v2.0.0

Published

A plugin for Nera static site generator to emit schema.org JSON-LD structured data (site entity, WebSite, BlogPosting) in the head of every page.

Readme

@nera-static/plugin-structured-data

Test npm version

A plugin for the Nera static site generator that puts schema.org structured data into the <head> of every page, as one JSON-LD @graph: who runs the site (an Organization, a LocalBusiness such as ProfessionalService, or a Person), the WebSite, a BlogPosting on every blog post, and an Event on the pages that announce one.

📖 Documentation: nera.js.org

✨ Features

  • One JSON-LD block per page, with the site entity and the WebSite on every page and a BlogPosting on the pages you mark as posts
  • An opt-in Event node from an event: mapping in the frontmatter
  • An opt-in BreadcrumbList from the index pages of a page's folders
  • Nodes linked by stable @ids (https://example.com/#entity), so author and publisher always resolve
  • Absolute, percent-encoded URLs that honour base_path, the same URLs @nera-static/plugin-sitemap lists
  • Multilingual: one graph per page in the page's language, with per-language config values
  • Article dates from the frontmatter in UTC, event dates as you wrote them, opening hours, a postal address, profile links, and a passthrough for any other schema.org property
  • A frontmatter structured_data escape hatch to extend, override or drop a page's node
  • Safe output (</script> cannot break out) and byte-identical for the same site

🚀 Installation

npm install @nera-static/plugin-structured-data

Nera detects the plugin during nera build. It needs two things from your site.

The site's origin in config/app.yaml, because structured data needs absolute URLs:

origin: https://example.com

A site that already uses @nera-static/plugin-canonical-links can keep its origin there instead: without origin in config/app.yaml the plugin reads app_origin from config/canonical-links.yaml.

And, usually, a config/structured-data.yaml that describes the site entity:

entity:
    type: Organization
    name: Example Ltd.

Without entity.name the entity is named after name in config/app.yaml, so a site without the file still gets an Organization with the site's name. Without either name, or without an origin, the build prints one hint and the pages get no structured data. Nothing else changes.

🧩 Usage

Publish the view (see Template Publishing) and include it in the <head> of your layout:

head
    include /vendor/plugin-structured-data/index

The leading slash makes the path root-absolute: it resolves against your views folder (theme/views/ on a site scaffolded with nera new), wherever the including file sits. A page without structured data (no config, or structured_data: false) gets no tag at all.

Plugin order

The plugin gives structured data only to the pages that exist when it runs. Plugins run in alphabetical order by default, so a plugin that adds pages and sorts after it, such as @nera-static/plugin-tags with its tag pages, adds them too late. List this plugin under end: in config/plugin-order.yaml so it runs after every page exists, and after @nera-static/plugin-images has created the Open Graph image:

plugin-order:
    - end:
          - plugin-structured-data

If end: already lists plugins, such as plugin-canonical-links, add it to the same list. The order among them does not matter.

⚙️ Configuration

The package ships an annotated config/structured-data.yaml with every key (node_modules/@nera-static/plugin-structured-data/config/structured-data.yaml); copy it into your site's config/ folder and edit it there. Every key is optional; set entity.name when the entity's name differs from the site's name.

entity: who runs the site

| Key | Type | Written as | Default | | --- | --- | --- | --- | | type | schema.org type, or a list of types | @type | Organization | | name | text | name | name from config/app.yaml; one of the two is required for any output | | url | URL | url | the site root, <site>/ | | logo | URL | logo | omitted | | image | URL | image | omitted | | description | text | description | omitted | | email | text | email | omitted | | telephone | text | telephone | omitted | | address | one-line text, or a PostalAddress mapping | address | omitted | | same_as | URL or list of URLs | sameAs | omitted | | area_served | text or list | areaServed (a list) | omitted | | opening_hours | entry or list of entries | openingHoursSpecification | omitted | | properties | mapping | copied into the entity as is | none |

  • type is any schema.org type: Organization, LocalBusiness or one of its subtypes (ProfessionalService, Restaurant, …), or Person.

  • URLs: an absolute URL (https://…, mailto:…) is kept as it is; a path (/img/logo.png) is made absolute against the origin and base_path and percent-encoded like a page URL (/img/größe 1.png → /img/gr%C3%B6%C3%9Fe%201.png; an existing %XX escape stays as it is).

  • address as a mapping takes schema.org's property names: streetAddress, postalCode, addressLocality, addressRegion, addressCountry.

  • opening_hours uses schema.org's openingHours notation: days Mo Tu We Th Fr Sa Su, as a range (Mo-Fr) or a list (Mo,We,Fr), then one or more time ranges (09:00-12:00,13:00-17:00). 24:00 as a closing time means midnight. An entry that does not parse is left out with a warning.

  • For a LocalBusiness (or a subtype), Google's Rich Results Test recommends an image and a priceRange (€€, or a range such as 50–100 €); without them it reports "missing field" warnings, which do not block the rich result. Set image above and priceRange under properties.

  • To list the products or services a business maintains, use brand with Brand nodes under properties (schema.org: "the brand(s) maintained by an organization or business person"), not owns with Product nodes. Google's Rich Results Test checks every Product as a product snippet, which needs offers, review or aggregateRating, and reports each one without them as invalid. Brand does not trigger those checks; it does not earn a rich result of its own either.

    entity:
        properties:
            brand:
                - '@type': Brand
                  name: Nera
                  url: https://nera.js.org
                - '@type': Brand
                  name: Example App
                  url: https://example.com/app
  • properties is for anything the keys above do not model, such as founder, knowsAbout, brand or priceRange. It cannot set a key the table already covers (@id, @type, name, url, logo, image, description, email, telephone, address, sameAs, areaServed, openingHoursSpecification); such a key is ignored with a warning.

website: the WebSite node

| Key | Type | Default | | --- | --- | --- | | name | text | name from config/app.yaml |

articles: which pages are posts

| Key | Type | Default | | --- | --- | --- | | key | frontmatter key | is_blog_{lang} | | type | schema.org type | BlogPosting |

A page whose frontmatter sets key to a true value gets an article node of type. {lang} in the key is replaced by the page's language, so with the default a German post sets is_blog_de: true and an English one is_blog_en: true. On a site without any language, the default reads is_blog. Use type: Article or NewsArticle for other kinds of articles.

events: which pages announce an event

| Key | Type | Default | | --- | --- | --- | | key | frontmatter key | event |

A page whose frontmatter has a mapping under key gets an Event node; see Events. If your pages already use event: for something else, set another key here, or every such page warns.

breadcrumbs: a trail per page

| Key | Type | Default | | --- | --- | --- | | breadcrumbs | true or false | false |

breadcrumbs: true

With true, every page gets a BreadcrumbList node <page URL>#breadcrumbs. Its trail is the index page of each folder above the page, from the top down, then the page itself; each item has position, name (the page's title) and item (its absolute URL, see Generated Output). For pages/de/blog/2026/first.md:

| position | name | item | | --- | --- | --- | | 1 | title of pages/de/index.md | https://example.com/de/index.html | | 2 | title of pages/de/blog/index.md | https://example.com/de/blog/index.html | | 3 | title of the page | https://example.com/de/blog/2026/first.html |

  • A folder whose index page is missing, has no layout (Nera does not render it) or no title is skipped; above, pages/de/blog/2026/ has none.
  • An index page in another language than the page is skipped too, so a German trail starts at /de/index.html, not at the English home page.
  • An index page lists itself once, as the last item. A trail of fewer than two items, such as the home page's, is left out, as Google requires at least two. A page without a title gets no trail.

Languages

entity.name, url, logo, image, description, email and telephone, each value of an address mapping, each area_served entry, and website.name may instead be a map keyed by language:

entity:
    name: Example GmbH
    description:
        de: Webentwicklung in Berlin
        en: Web development in Berlin

A page's language is its frontmatter lang, else lang from config/app.yaml, with surrounding whitespace trimmed; a blank lang counts as absent. A map without an entry for the page's language falls back to the site's lang, and else the field is left out (entity.name and website.name then use name from config/app.yaml). properties is copied without language resolution.

Invalid values

A value of the wrong type, or an unknown key, prints a warning naming it and is ignored; the default stays in place. Keys every JavaScript object inherits, such as constructor, count as unknown too, at the top level and in every block. A typo in the config never fails the build. See Warnings for the wording.

Blog posts

The article node is built from the page's frontmatter:

| Field | From | | --- | --- | | headline | title | | description | description, else sub_title | | datePublished | the first of date, datePublished, published that holds a date | | dateModified | the first of updated, updatedAt, lastmod, dateModified that holds a date, else the datePublished above | | image | the Open Graph crop of @nera-static/plugin-images (meta.images.image.og.src), else image | | author, publisher | the site entity, by @id | | inLanguage | the page's language | | url, mainEntityOfPage | the page URL |

---
layout: pages/post.pug
title: Hello
description: The first post.
is_blog_en: true
date: 2026-10-01
updated: 2026-10-08T09:30:00Z
image: /img/hello.jpg
---

Dates:

  • Article dates are written in UTC, with a time and a Z, because Google's Rich Results Test flags a date without a time zone as an invalid date/time. A day alone (2026-10-01) becomes midnight UTC, 2026-10-01T00:00:00Z; a time with an offset becomes the same moment in UTC (2026-10-08T09:30:00+02:00 → 2026-10-08T07:30:00Z); a time without an offset is read as UTC (2026-10-08 09:30 → 2026-10-08T09:30:00Z), never in the build machine's time zone. Milliseconds are left out.
  • A date is a YAML date or a string YYYY-MM-DD, optionally followed by T or a space and hh:mm[:ss], and an optional Z or ±hh:mm offset. A day or time that does not exist (2026-02-30, 24:00) and other forms (1.10.2026, an offset +0200 without the colon) are not dates.
  • The keys are tried in the order above. A key whose value is not a date prints a warning naming the page and the key, and the next key is tried.
  • A post without a usable update key gets its datePublished as dateModified, the honest value for a post never edited.
  • createdAt is never read. Nera fills it from the file's creation date when the frontmatter has none, and on CI every file is created at the time of the build, so it would date every post to the last deploy. A post without any of the keys above gets neither datePublished nor dateModified: give every post a date:.

Events

A page with an event: mapping in its frontmatter gets an Event node <page URL>#event, next to its other nodes:

---
layout: pages/default.pug
title: Nera meetup
description: An evening about static sites.
image: /img/meetup.jpg
event:
    startDate: '2026-12-03T19:00:00+01:00'
    endDate: '2026-12-03T22:00:00+01:00'
    location:
        name: Example Hall
        address:
            streetAddress: Example Street 1
            postalCode: '10115'
            addressLocality: Berlin
            addressCountry: DE
    eventStatus: https://schema.org/EventScheduled
---

| Field | From | | --- | --- | | name | event.name, else title | | startDate | event.startDate, required | | endDate | event.endDate | | location | event.location: a text becomes a Place with that name; a mapping becomes a Place (or the @type it sets), its address mapping a PostalAddress | | description | event.description, else description | | image | event.image, else the image a post would get (see Blog posts) | | organizer | the site entity, by @id | | inLanguage | the page's language | | url | the page URL |

  • Every other key of the mapping is copied into the node as it is, such as eventStatus, offers, performer, or a subtype as @type (MusicEvent, BusinessEvent, …). It may also replace organizer. A YAML date among them is written in UTC (a day as 2026-12-03, a time as 2026-12-03T18:30:00Z), a quoted string as it is.
  • startDate and endDate are written as you wrote them, unlike the article dates: an offset-less '2026-12-03T19:00' is the venue's local time, and converting it to UTC would move the event by hours. Only a space between date and time becomes T, and a space before the offset is dropped. They take the same forms as the article dates; a date that does not exist is not one.
  • Google asks for a date and time with an offset (2026-12-03T19:00:00+01:00), or the date alone for an all-day event (2026-12-03). Quote a date with a time, as above: unquoted, YAML turns it into a point in time, which is written in UTC (2026-12-03T18:00:00Z), the same moment without your offset.
  • Google requires name, startDate and a location with a postal address for an event to show as a rich result. Give location as a mapping with an address; a plain venue name is valid schema.org but not enough for Google.
  • Without a startDate, with one that is not a date, or with an event: that is not a mapping, the page gets no Event and the build warns, naming the page. An endDate or location that cannot be read is left out with a warning. The node's @id is fixed; setting it is ignored with a warning.
  • structured_data: false drops the event too. The structured_data escape hatch changes the page node, not the event.

The structured_data escape hatch

A page's frontmatter can change its own node with structured_data.

Extend or override the generated BlogPosting. The keys are merged over it, one level deep: a nested value replaces the generated one entirely, and a key set to null removes it.

structured_data:
    '@type': TechArticle
    keywords: [nera, json-ld]
    image: null

Add a node to a page that is not a post. It starts from @id, url and inLanguage and needs its own @type:

structured_data:
    '@type': ContactPage
    name: Contact

Drop the page's structured data entirely, the entity and WebSite included:

structured_data: false

The page node's @id is always <page URL>#page; setting @id is ignored with a warning, so a page can never take over the entity's id. A node without @type, or a structured_data that is neither a mapping nor false, prints a warning naming the page and is ignored: the page gets its normal structured data. A YAML date inside the mapping is written in UTC (a day as 2026-12-03, a time as 2026-12-03T18:30:00Z), a quoted string as it is. The plugin always writes valid JSON with an @context; a JSON-LD block you write by hand into a layout has no such guarantee, and nera check finds a broken one, see Checking the output.

Examples

A freelancer's business with a founder, a brand, an address, opening hours and profiles, on a German and English site:

entity:
    type: ProfessionalService
    name: Michael Becker
    url: /
    logo: /img/logo.png
    description:
        de: Webentwicklung in Berlin
        en: Web development in Berlin
    email: [email protected]
    telephone: '+49 30 1234567'
    address:
        streetAddress: Example Street 1
        postalCode: '10115'
        addressLocality: Berlin
        addressCountry: DE
    area_served: Berlin
    opening_hours: Mo-Fr 09:00-17:00
    same_as:
        - https://github.com/example
        - https://www.linkedin.com/in/example
    properties:
        founder:
            '@type': Person
            name: Michael Becker
        knowsAbout:
            - Web development
            - Static sites
        brand:
            - '@type': Brand
              name: Nera
              url: https://nera.js.org

articles:
    key: is_blog_{lang}

A personal site:

entity:
    type: Person
    name: Jane Doe
    image: /img/jane.jpg
    same_as: https://github.com/janedoe

A site deployed under base_path: /docs/ writes every URL and id under https://example.com/docs/, the same URLs @nera-static/plugin-sitemap lists.

🛠️ Template Publishing

Copy the view into your project:

npx nera-structured-data

This copies index.pug to theme/views/vendor/plugin-structured-data/ (on an older site without a theme/ folder, to views/vendor/plugin-structured-data/). Inside the package, npm run publish-template does the same.

Publishing skips if that directory already exists, so your edits are never overwritten. To pull in an updated view after an upgrade, discarding your changes to it, run npx nera-structured-data --force.

The view is two lines of Pug:

if meta && meta.structuredData
    script(type='application/ld+json')!= meta.structuredData

meta.structuredData is the page's graph as a JSON string, already escaped: <, > and & are written as \u003c, \u003e and \u0026, which JSON reads back as the same characters. That is what makes the unescaped != safe. If you write your own view, print the string exactly like this and never build it from other values.

🎨 Styling

Nothing to style: the view writes one <script type="application/ld+json"> into the page's <head>, without classes, and browsers do not display it.

📊 Generated Output

For a blog post at https://example.com/blog/hello.html (the whitespace differs, since Nera formats the HTML it writes):

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@graph": [{
    "@id": "https://example.com/#entity",
    "@type": "Organization",
    "name": "Example Ltd.",
    "url": "https://example.com/"
  }, {
    "@id": "https://example.com/#website",
    "@type": "WebSite",
    "inLanguage": "en",
    "name": "Example",
    "publisher": { "@id": "https://example.com/#entity" },
    "url": "https://example.com/"
  }, {
    "@id": "https://example.com/blog/hello.html#page",
    "@type": "BlogPosting",
    "author": { "@id": "https://example.com/#entity" },
    "dateModified": "2026-10-01T00:00:00Z",
    "datePublished": "2026-10-01T00:00:00Z",
    "headline": "Hello",
    "inLanguage": "en",
    "mainEntityOfPage": "https://example.com/blog/hello.html",
    "publisher": { "@id": "https://example.com/#entity" },
    "url": "https://example.com/blog/hello.html"
  }]
}
</script>

Every other page gets the first two nodes only. The ids are part of the plugin's contract and do not depend on the entity's type:

| Node | @id | | --- | --- | | site entity | <site>/#entity | | WebSite | <site>/#website | | the page's node (BlogPosting, or your own via structured_data) | <page URL>#page | | Event (opt-in, see Events) | <page URL>#event | | BreadcrumbList (opt-in, see breadcrumbs) | <page URL>#breadcrumbs |

<site> is the origin without surrounding whitespace or a trailing slash, plus base_path (https://example.com/sub). <page URL> is <site> plus the page's path, percent-encoded: /blog/hello.html stays as it is, /blog/über uns.html becomes /blog/%C3%BCber%20uns.html. That is the URL @nera-static/plugin-sitemap lists as <loc>. For a path in plain ASCII it is also the URL @nera-static/plugin-canonical-links writes into <link rel="canonical">; for other paths, canonical-links 2.2.4 and older write the path unencoded, so the two differ until canonical-links encodes the same way. Empty fields are left out, never written as "" or null, and the keys are sorted, so the same site always gives the same output.

The plugin writes meta.structuredData on every page with a layout. It adds nothing to app and writes no files.

Checking the output

nera check and nera build --check run the output rule seo-jsonld of @nera-static/validate (1.8.0 or later; npm update brings it into an existing site through @nera-static/nera). It warns, with file and line, about a <script type="application/ld+json"> block that is empty or not valid JSON, or whose top-level object (or an item of its top-level array) has no @context. Such a block is invisible in the browser, and search engines ignore it whole. The rule does not check whether the types and properties are valid schema.org, nor Google's requirements for a rich result: test a built page with the Schema Markup Validator and Google's Rich Results Test for that. To silence the rule on some paths, list them in config/validate.yaml:

ignore:
    seo-jsonld: [public/legacy]

⚠️ Warnings

Each problem prints one line and the build goes on. Without an origin or a name, the pages get no structured data:

⚠️ plugin-structured-data: no site origin, so no structured data was emitted. Set `origin` in config/app.yaml (or `app_origin` in config/canonical-links.yaml).
⚠️ plugin-structured-data: neither config/structured-data.yaml (`entity.name`) nor config/app.yaml (`name`) names the site, so no structured data was emitted. Set `name` in config/app.yaml, or add config/structured-data.yaml with `entity.name` (the package ships an annotated structured-data.yaml).

A config value that cannot be used keeps its default, once per build:

⚠️ plugin-structured-data: config/structured-data.yaml: invalid entity.type 42, using "Organization"
⚠️ plugin-structured-data: config/structured-data.yaml: invalid entity.name ["x"], ignoring it
⚠️ plugin-structured-data: config/structured-data.yaml: ignoring unknown key entity."nmae"

A frontmatter value that cannot be used names the page:

⚠️ plugin-structured-data: /blog/hello.html: ignoring date "soon", expected a date like 2026-10-01 or 2026-10-01T09:30:00Z
⚠️ plugin-structured-data: /events/meetup.html: ignoring event, unparseable startDate "next Friday"

🧩 Compatibility

  • Nera (@nera-static/core): 4.3.0 or later for the root-absolute include /vendor/… shown in Usage; the theme/ folder that nera new scaffolds needs 4.6.0 or later.
  • @nera-static/plugin-canonical-links: optional. Its app_origin is used when config/app.yaml has no origin. On a base_path site, versions before 2.2.3 leave base_path out of the canonical URL, so it disagrees with this plugin's URLs; update it. For a page path outside ASCII, 2.2.4 and older write the canonical URL unencoded, so it differs from this plugin's percent-encoded URL (see Generated Output).
  • Plugin order: list the plugin under end: in config/plugin-order.yaml, so the pages other plugins add get structured data too (see Plugin order).
  • Node.js: 22.12.0 or later, like @nera-static/core.

🧪 Development

npm install
npx vitest run
npm run lint

npm run test:watch runs Vitest in watch mode. npm run lint runs nera-stan, the Nera style check. The integration tests build throwaway sites with the real @nera-static/core in a temp directory and parse the JSON-LD out of the written pages.

🤝 Contributing

See the Nera contributing guide and the style guide.

📦 License

MIT, see LICENSE.