DEV Community

Cover image for Boost Rich Results with Automated JSON-LD Schema for Blogs
Carllowman
Carllowman

Posted on

Boost Rich Results with Automated JSON-LD Schema for Blogs

Just built a quick script to generate JSON-LD schema for my blog posts automatically. No more manual copy-paste from Google's Structured Data Testing Tool.

The idea: parse the article's title, description, publish date, and author from frontmatter, then output a valid Article schema.

python
import frontmatter
import json

def generate_article_schema(post):
schema = {
"@context": "https://schema.org",
"@type": "Article",
"headline": post['title'],
"description": post.get('description', ''),
"datePublished": post['date'],
"author": {
"@type": "Person",
"name": post['author']
}
}
return json.dumps(schema, indent=2)

Example usage

post = frontmatter.load('my-post.md')
schema = generate_article_schema(post.metadata)
print(schema)

This handles basic articles, but for richer types like FAQ, Recipe, or Product, you need more fields. I've been using SERPSpur's Schema Markup Generator to handle those complex cases — it outputs clean JSON-LD that passes validation.

The biggest benefit? Google started showing my posts in rich results within a week. Traffic from featured snippets went up by about 15%.

What schema types have you found most impactful for SEO?

https://serpspur.com

Top comments (0)