Color mode

SEO

SEO metadata, sitemap, robots.txt, and feed generation for Riebeckite.

日本語

Overview

seo() provides a PluginSeoExtension consumed by the Riebeckite app. It builds per-page SEO metadata and renders /sitemap.xml, /robots.txt, and RSS / Atom / JSON feeds.

Usage

ts
import { defineConfig } from "@riebeckite/core";
import { seo } from "@riebeckite/plugin-seo";
 
export default defineConfig({
  // ...
  plugins: [
    seo({
      feed: { rss: true, atom: true, json: true, limit: 30 },
      sitemap: true,
      robots: true,
    }),
  ],
});

Options

Option Type Description
feed { rss?: boolean; atom?: boolean; json?: boolean; limit?: number } Feed output settings. limit defaults to 30 and applies to every format.
sitemap boolean Sitemap output settings.
robots boolean robots.txt output settings.

Generated metadata

Articles (buildArticleSeo)

  • title: "{title} | {site.title}"
  • description: frontmatter.description, otherwise the first 160 characters of the post text
  • canonicalUrl: frontmatter.canonical, otherwise the entry's resolved canonical permalink
  • imageUrl: frontmatter.ogImage / frontmatter.image, otherwise site.defaultOgImage
  • noindex: frontmatter.noindex === true
  • publishedTime: published / date / created
  • modifiedTime: updated, falling back to the publish time
  • tags, readingTimeMinutes
  • JSON-LD: BlogPosting and BreadcrumbList

Pass the page's headTags when they already include a BreadcrumbList (for example contributed by the breadcrumbs plugin) and this plugin omits its own list, so the page keeps a single BreadcrumbList entity.

Websites (buildWebsiteSeo)

Title, description, canonical URL, default image, and JSON-LD WebSite + BreadcrumbList for index, tag, and other non-article pages. The BreadcrumbList is omitted under the same headTags condition as articles.

Feeds, sitemap, and robots

Function Output
renderSitemap /sitemap.xml — home page plus published, non-noindex entries
renderRobots /robots.txt — allow all plus sitemap link
renderRssFeed RSS 2.0 built from config.site.feed
renderAtomFeed Atom feed
renderJsonFeed JSON Feed 1.1 with content_html

Feed and sitemap entries are filtered with isPublished, exclude noindex: true, and are sorted by the most recent update first. Their URLs use each entry's resolved canonical permalink (ContentManifestEntry.permalink); they are never rebuilt from slugs. Feeds include the latest 30 entries by default. Set feed.limit to change the shared limit for RSS, Atom, and JSON Feed.

Reading time

calculateReadingTime counts CJK characters (500/min) and Latin words (220/min), rounding up to at least 1 minute.

Frontmatter fields

Field Use
title Article title (falls back to the last slug segment)
description Meta description
canonical Canonical URL
image / ogImage OG image
published / date / created Publish time
updated Modified time
tags Keywords / feed tags
noindex noindex meta, feed and sitemap exclusion

Exports

  • seo(options?) — plugin factory
  • Types: SeoPluginOptions, FeedOptions, SeoMetadata, WebsiteSeoInput, RenderableFeedEntry
  • Helpers: buildArticleSeo, buildWebsiteSeo, buildAbsoluteUrl, buildPostUrl, getDescription, filterFeedEntries, getEntryPublishedTime, getEntryUpdatedTime, getHtmlLanguage, calculateReadingTime, renderSitemap, renderRobots, renderRssFeed, renderAtomFeed, renderJsonFeed

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/seo/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # SEO
4 +
5 + SEO metadata, sitemap, robots.txt, and feed generation for Riebeckite.
6 +
7 + [日本語](./seo.md)
8 +
9 + ## Overview
10 +
11 + `seo()` provides a `PluginSeoExtension` consumed by the Riebeckite app. It
12 + builds per-page SEO metadata and renders `/sitemap.xml`, `/robots.txt`, and
13 + RSS / Atom / JSON feeds.
14 +
15 + ## Usage
16 +
17 + ```ts
18 + import { defineConfig } from "@riebeckite/core";
19 + import { seo } from "@riebeckite/plugin-seo";
20 +
21 + export default defineConfig({
22 + // ...
23 + plugins: [
24 + seo({
25 + feed: { rss: true, atom: true, json: true, limit: 30 },
26 + sitemap: true,
27 + robots: true,
28 + }),
29 + ],
30 + });
31 + ```
32 +
33 + ## Options
34 +
35 + | Option | Type | Description |
36 + | ------ | ---- | ----------- |
37 + | `feed` | `{ rss?: boolean; atom?: boolean; json?: boolean; limit?: number }` | Feed output settings. `limit` defaults to 30 and applies to every format. |
38 + | `sitemap` | `boolean` | Sitemap output settings. |
39 + | `robots` | `boolean` | robots.txt output settings. |
40 +
41 + ## Generated metadata
42 +
43 + ### Articles (`buildArticleSeo`)
44 +
45 + - `title`: `"{title} | {site.title}"`
46 + - `description`: `frontmatter.description`, otherwise the first 160 characters
47 + of the post text
48 + - `canonicalUrl`: `frontmatter.canonical`, otherwise the entry's resolved canonical permalink
49 + - `imageUrl`: `frontmatter.ogImage` / `frontmatter.image`, otherwise
50 + `site.defaultOgImage`
51 + - `noindex`: `frontmatter.noindex === true`
52 + - `publishedTime`: `published` / `date` / `created`
53 + - `modifiedTime`: `updated`, falling back to the publish time
54 + - `tags`, `readingTimeMinutes`
55 + - JSON-LD: `BlogPosting` and `BreadcrumbList`
56 +
57 + Pass the page's `headTags` when they already include a BreadcrumbList (for
58 + example contributed by the breadcrumbs plugin) and this plugin omits its own
59 + list, so the page keeps a single BreadcrumbList entity.
60 +
61 + ### Websites (`buildWebsiteSeo`)
62 +
63 + Title, description, canonical URL, default image, and JSON-LD `WebSite` +
64 + `BreadcrumbList` for index, tag, and other non-article pages. The
65 + BreadcrumbList is omitted under the same `headTags` condition as articles.
66 +
67 + ## Feeds, sitemap, and robots
68 +
69 + | Function | Output |
70 + | -------- | ------ |
71 + | `renderSitemap` | `/sitemap.xml` — home page plus published, non-`noindex` entries |
72 + | `renderRobots` | `/robots.txt` — allow all plus sitemap link |
73 + | `renderRssFeed` | RSS 2.0 built from `config.site.feed` |
74 + | `renderAtomFeed` | Atom feed |
75 + | `renderJsonFeed` | JSON Feed 1.1 with `content_html` |
76 +
77 + Feed and sitemap entries are filtered with `isPublished`, exclude
78 + `noindex: true`, and are sorted by the most recent update first. Their URLs use
79 + each entry's resolved canonical `permalink` (`ContentManifestEntry.permalink`);
80 + they are never rebuilt from slugs.
81 + Feeds include the latest 30 entries by default. Set `feed.limit` to change the
82 + shared limit for RSS, Atom, and JSON Feed.
83 +
84 + ## Reading time
85 +
86 + `calculateReadingTime` counts CJK characters (500/min) and Latin words
87 + (220/min), rounding up to at least 1 minute.
88 +
89 + ## Frontmatter fields
90 +
91 + | Field | Use |
92 + | ----- | --- |
93 + | `title` | Article title (falls back to the last slug segment) |
94 + | `description` | Meta description |
95 + | `canonical` | Canonical URL |
96 + | `image` / `ogImage` | OG image |
97 + | `published` / `date` / `created` | Publish time |
98 + | `updated` | Modified time |
99 + | `tags` | Keywords / feed tags |
100 + | `noindex` | `noindex` meta, feed and sitemap exclusion |
101 +
102 + ## Exports
103 +
104 + - `seo(options?)` — plugin factory
105 + - Types: `SeoPluginOptions`, `FeedOptions`, `SeoMetadata`, `WebsiteSeoInput`,
106 + `RenderableFeedEntry`
107 + - Helpers: `buildArticleSeo`, `buildWebsiteSeo`, `buildAbsoluteUrl`,
108 + `buildPostUrl`, `getDescription`, `filterFeedEntries`,
109 + `getEntryPublishedTime`, `getEntryUpdatedTime`, `getHtmlLanguage`,
110 + `calculateReadingTime`, `renderSitemap`, `renderRobots`, `renderRssFeed`,
111 + `renderAtomFeed`, `renderJsonFeed`
112 +
113 + ## See also
114 +
115 + - [Plugin guide](../reference/plugin-api.en.md)
116 +