Skip to content

Add JSON-LD plugin for blog posts#17

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/create-statiq-plugin-jsonld
Draft

Add JSON-LD plugin for blog posts#17
Copilot wants to merge 3 commits intomainfrom
copilot/create-statiq-plugin-jsonld

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 18, 2026

Implements a new Statiq plugin that generates a schema.org/BlogPosting JSON-LD representation for blog posts, adding it as document metadata for inclusion in page templates.

New classes

  • JsonLdModuleParallelModule that runs on IsPost documents, builds a BlogPosting JSON object from available metadata, and stores it as a JsonLd string property on the document
  • JsonLdConfiguratorIConfigurator<Bootstrapper> that registers JsonLdModule into the Content pipeline's ProcessModules

Metadata mapping

JSON-LD field Source
headline Title
description Lead / Description
datePublished Published (ISO 8601)
image Image (absolute URL)
url Document link (absolute URL)
author Author (document or site settings)
publisher SiteTitle
keywords Tags

Usage

Register in Program.cs:

return await Bootstrapper
  .Factory
  .CreateWeb(args)
  .AddConfigurator(new JsonLdConfigurator())
  .RunAsync();

Render in input/_head.cshtml:

@if (Document.ContainsKey("JsonLd"))
{
  <script type="application/ld+json">@Html.Raw(Document.GetString("JsonLd"))</script>
}

Sample project

The sample project has been updated to demonstrate the plugin in action:

  • sample/Program.cs — registers both ReadingTimeConfigurator and JsonLdConfigurator
  • sample/appsettings.json — added Author setting to populate the JSON-LD author field
  • sample/input/_head.cshtml — new file overriding the CleanBlog theme's _head partial to inject the <script type="application/ld+json"> tag into the page <head>

Running the sample produces the following JSON-LD for a blog post:

{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "1",
  "description": "Sub title",
  "datePublished": "2023-01-01T00:00:00Z",
  "image": "https://alex-hedley.github.io/posts/images/background.jpg",
  "url": "https://alex-hedley.github.io/posts/1",
  "author": { "@type": "Person", "name": "Alex Hedley" },
  "publisher": { "@type": "Organization", "name": "Alex Hedley" },
  "keywords": "thoughts, learning"
}

Copilot AI linked an issue Apr 18, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/d5d4b9e3-2a52-4ca8-bb6f-5e03a1b35309

Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Statiq plugin for JSONLD representation of blog posts Add JSON-LD plugin for blog posts Apr 18, 2026
Copilot AI requested a review from AlexHedley April 18, 2026 13:00
@AlexHedley
Copy link
Copy Markdown
Owner

@copilot add/update the site project in the sample folder to use the plugin and confirm that it is working

Copy link
Copy Markdown
Author

Copilot AI commented Apr 18, 2026

@copilot add/update the site project in the sample folder to use the plugin and confirm that it is working

Done in e17a391. Three changes to the sample:

  1. sample/Program.cs — registers both ReadingTimeConfigurator and JsonLdConfigurator
  2. sample/appsettings.json — added "Author": "Alex Hedley" so the JSON-LD author field is populated
  3. sample/input/_head.cshtml — new file that overrides the CleanBlog theme's empty _head partial to inject the <script type="application/ld+json"> tag into the page <head>

Running the sample generates the following JSON-LD in posts/1.html:

{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "1",
  "description": "Sub title",
  "datePublished": "2023-01-01T00:00:00Z",
  "image": "https://alex-hedley.github.io/posts/images/background.jpg",
  "url": "https://alex-hedley.github.io/posts/1",
  "author": { "@type": "Person", "name": "Alex Hedley" },
  "publisher": { "@type": "Organization", "name": "Alex Hedley" },
  "keywords": "thoughts, learning"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSONLD Metadata

2 participants