From 487d2528cb2e885644c111b95354c84523c7840e Mon Sep 17 00:00:00 2001 From: Claudio Chies <61051109+Claudio-Chies@users.noreply.github.com> Date: Wed, 17 Jun 2026 03:10:13 +0200 Subject: [PATCH] Improve search-engine crawlability of docs (#719) --- .vitepress/config.mjs | 32 ++++++++++++++++++++++++++++++++ package.json | 1 - public/robots.txt | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 public/robots.txt diff --git a/.vitepress/config.mjs b/.vitepress/config.mjs index e689f50c..267a9a4b 100644 --- a/.vitepress/config.mjs +++ b/.vitepress/config.mjs @@ -12,6 +12,10 @@ export default defineConfig({ description: "MAVLink Developer Guide", //base: process.env.BRANCH_NAME ? "/" + process.env.BRANCH_NAME + "/" : "", //Build doesn't use branches! base: "", + lastUpdated: true, + sitemap: { + hostname: "https://mavlink.io", + }, srcExclude: [ "de/**/*.md", "ja/**/*.md", @@ -115,8 +119,36 @@ export default defineConfig({ }, }, //Logs every page loaded on build. Good way to catch errors not caught by other things. + //Also injects per-page SEO metadata (description, OpenGraph, canonical) into the + //server-rendered
so message pages are better crawled/snippeted by search engines. async transformPageData(pageData, { siteConfig }) { console.log(pageData.filePath); + + const desc = + pageData.frontmatter.description || + pageData.description || + (pageData.title + ? `${pageData.title} — MAVLink message, enum and command reference.` + : "MAVLink Developer Guide"); + + // Set pageData.description so VitePress's own uses it + // (pushing a second description tag in head would be deduped in favour of the default). + pageData.description = desc; + + const url = + "https://mavlink.io/" + + pageData.relativePath + .replace(/(^|\/)index\.md$/, "$1") + .replace(/\.md$/, ".html"); + + pageData.frontmatter.head ??= []; + pageData.frontmatter.head.push( + ["meta", { property: "og:title", content: pageData.title }], + ["meta", { property: "og:description", content: desc }], + ["meta", { property: "og:type", content: "article" }], + ["meta", { property: "og:url", content: url }], + ["link", { rel: "canonical", href: url }] + ); }, // diff --git a/package.json b/package.json index dc40e787..73da629e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "docs:buildwin": "set NODE_OPTIONS=--max_old_space_size=8192 && vitepress build .", "docs:build_ubuntu": "NODE_OPTIONS='--max-old-space-size=8192' vitepress build .", "docs:preview": "vitepress preview .", - "docs:sitemap": "python3 ./scripts/gen_sitemap.py", "docs:gen_alt_sidebar_ubuntu": "python3 ./scripts/gen_alt_sidebar.py", "docs:get_alt_sidebar_windows": "python ./scripts/gen_alt_sidebar.py", "start": "yarn docs:dev", diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 00000000..fc0b9633 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +User-agent: * + +Sitemap: https://mavlink.io/sitemap.xml