コンテンツにスキップ

[WARN] [@astrojs/sitemap] The Sitemap integration requires the ...

Terminal window
[WARN] [@astrojs/sitemap] The Sitemap integration requires the `site` astro.config option. Skipping.

 この警告は,cloudflare pages上でAstroをビルドしたときのログに出力されたもの.astro.config.mjssiteオプションがないため,サイトマップが作れず,スキップしたようだ.

参考サイト

当時の環境

  • node : v20.15.1
  • astro: 4.13.1
  • @astrojs/starlight: 0.25.4

astro.configにsiteを追加する.

 警告文のとおり,astro.config.mjsに以下のようにsiteを追加すればよい.追加するURLは自分のWebサイトのものを.

astro.config.mjs
export default defineConfig({
site: 'https://xxx.example.com',
integrations: [...],
...

 すると数学の主張でいえば,sitemap-index.xmlが作成される.

ライブラリの追加は不要.

 検索すると,@astrojs/sitemapをインストールする記事が出てくるが,すでに入っているので,やらなくてよい.siteだけ追加すれば,ビルド時に生成してくれる.