[WARN] [@astrojs/sitemap] The Sitemap integration requires the ...
Astroでビルドを実行した際、ターミナルに以下のような警告が出力され、サイトマップが生成されない場合がある。
この警告は、Cloudflare Pagesなどの環境でAstroをビルドしたときにも見られる。原因は astro.config.mjs に site オプションが設定されていないため、サイトマップの基準URLが特定できず、生成処理がスキップされていることである。
解決策:astro.config.mjsにsiteを追加する
Section titled “解決策:astro.config.mjsにsiteを追加する”警告文が示す通り、astro.config.mjs にサイトの基本URLを指定する site プロパティを追加すれば解決する。
-
astro.config.mjsを開く。 -
defineConfig内にsite: 'https://あなたのドメイン.com'を追記する。astro.config.mjs // astro.config.mjsexport default defineConfig({site: 'https://xxx.example.com',integrations: [...],// ...}); -
設定を保存し、再度ビルドを実行する。
これにより、ビルド時に public または dist ディレクトリへ sitemap-index.xml が正常に作成される(例: sitemap-index.xml)。
- Astroビルド時のサイトマップ関連警告は、
astro.config.mjsでのsite指定漏れが原因である。 defineConfig内に自身のWebサイトのURLをsite: 'https://...'として追記することで警告は消え、サイトマップが生成される。
参考サイト
環境情報
- node : v20.15.1
- astro: 4.13.1
- @astrojs/starlight: 0.25.4
他の記事を探す