Skip to main content

Module seo

Module seo 

Source
Expand description

Search engines and language models: JSON-LD, sitemaps and llms.txt.

  • json_ld: structured data (Organization, FAQPage, BreadcrumbList…) as a <script type="application/ld+json">, escaped so the JSON can never close the script element.
  • Sitemap: /sitemap.xml, with the other languages of each page (xhtml:link rel="alternate" hreflang) and lastmod.
  • LlmsTxt: /llms.txt, the Markdown index of a site for language models (https://llmstxt.org).

The canonical and hreflang links of a page come from the visitor’s locale: I18n::alternate_links. ocre g seo writes src/seo.rs with the routes and a list of pages.

One address per page: redirect_www sends www. + the host of APP_URL to APP_URL with a 301. IndexNow tells Bing, Yandex and others that pages changed without waiting for a crawl: indexnow_routes serves the key file, submit_to_indexnow sends the URLs.

Structs§

LlmsTxt
/llms.txt: a site’s summary and links in Markdown, for language models (https://llmstxt.org).
Sitemap
/sitemap.xml: the pages search engines should crawl.
SitemapUrl
A page of a Sitemap: its absolute URL, last change and other languages.

Constants§

INDEXNOW_ENDPOINT
The endpoint IndexNow submissions go to; participating engines share them.
INDEXNOW_KEY
Worker variable holding the IndexNow key: 8 to 128 letters, digits or - (ocre secret prints one).
INDEXNOW_KEY_PATH
Where indexnow_routes serves the key: /indexnow.txt (the submission names it as keyLocation).

Functions§

indexnow_routes
GET /indexnow.txt: the INDEXNOW_KEY, which search engines fetch to check a submission.
json_ld
data as a JSON-LD <script> for a page’s <head>.
redirect_www
Middleware sending www. + the host of APP_URL to APP_URL, same path and query, with 301 Moved Permanently.
submit_to_indexnow
Tells IndexNow-participating search engines (Bing, Yandex, Seznam, Naver…) that urls were added or changed.