Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Recipe imports are logged both here (summary) and in

### Added

- **Static site: SEO and Recipe structured data (ADR 0003, PR 3 of the site phase).**
Each recipe page now carries schema.org `Recipe` JSON-LD (name, author, category,
ingredients, step-by-step instructions, keywords, yield, and image) so search
engines can show rich results. Added canonical, Open Graph, and Twitter-card meta to
every page (recipe pages use their own photo and an `article` type; other pages use
the biscotti image). Added a generated `sitemap.xml` (507 URLs) and `robots.txt`
pointing at it. All absolute URLs use the `github.blimacake.com` domain.

- **Static site: full-text search (ADR 0003, PR 2 of the site phase).** Added a
`/search/` page powered by [Pagefind](https://pagefind.app/), a static search index
built from the site output (`npm run build` now runs `eleventy && pagefind`). Only
Expand Down
22 changes: 22 additions & 0 deletions eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ export default function (eleventyConfig) {

eleventyConfig.addFilter("limit", (arr, n) => (arr || []).slice(0, n));

// schema.org/Recipe structured data for a recipe, as an escaped JSON string
// safe to drop into a <script type="application/ld+json"> block.
eleventyConfig.addFilter("recipeJsonLd", (recipe, siteUrl) => {
const obj = {
"@context": "https://schema.org",
"@type": "Recipe",
name: recipe.title,
author: { "@type": "Person", name: "Blima Posluns" },
url: siteUrl + recipe.url,
recipeCategory: recipe.category,
recipeIngredient: recipe.ingredients,
recipeInstructions: (recipe.steps || []).map((text) => ({
"@type": "HowToStep",
text,
})),
};
if (recipe.tags && recipe.tags.length) obj.keywords = recipe.tags.join(", ");
if (recipe.yield) obj.recipeYield = recipe.yield;
if (recipe.heroImage) obj.image = [siteUrl + recipe.heroImage];
return JSON.stringify(obj).replace(/</g, "\\u003c");
});

return {
dir: {
input: "site",
Expand Down
8 changes: 8 additions & 0 deletions site/_includes/base.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{% if pageTitle %}{{ pageTitle }} &middot; {% endif %}{{ site.title }}</title>
<meta name="description" content="{{ pageDescription or site.description }}" />
<link rel="canonical" href="{{ site.url }}{{ page.url }}" />
<meta property="og:site_name" content="{{ site.title }}" />
<meta property="og:type" content="{% if pageImage %}article{% else %}website{% endif %}" />
<meta property="og:title" content="{{ pageTitle or site.title }}" />
<meta property="og:description" content="{{ pageDescription or site.description }}" />
<meta property="og:url" content="{{ site.url }}{{ page.url }}" />
<meta property="og:image" content="{{ site.url }}{{ pageImage or site.heroImage }}" />
<meta name="twitter:card" content="summary_large_image" />
<link rel="stylesheet" href="/assets/style.css" />
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions site/recipe.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ pagination:
permalink: "{{ recipe.url }}"
eleventyComputed:
pageTitle: "{{ recipe.title }}"
pageImage: "{{ recipe.heroImage }}"
pageDescription: "Blima's recipe for {{ recipe.title }}: ingredients and method."
---
<script type="application/ld+json">{{ recipe | recipeJsonLd(site.url) | safe }}</script>
<article class="recipe wrap" data-pagefind-body>
<nav class="crumbs" data-pagefind-ignore>
<a href="/">Home</a> &middot;
Expand Down
8 changes: 8 additions & 0 deletions site/robots.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
permalink: /robots.txt
eleventyExcludeFromCollections: true
---
User-agent: *
Allow: /

Sitemap: {{ site.url }}/sitemap.xml
14 changes: 14 additions & 0 deletions site/sitemap.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
permalink: /sitemap.xml
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>{{ site.url }}/</loc></url>
<url><loc>{{ site.url }}/categories/</loc></url>
<url><loc>{{ site.url }}/tags/</loc></url>
<url><loc>{{ site.url }}/search/</loc></url>
{% for cat in categories %}<url><loc>{{ site.url }}{{ cat.url }}</loc></url>
{% endfor %}{% for r in recipes %}<url><loc>{{ site.url }}{{ r.url }}</loc></url>
{% endfor %}
</urlset>
Loading