Site cover image

🤠astro-notion-blogでsitemap対応

このブログも、astro-notion-blog で生成しています。

素晴らしいツールを公開して頂きありがとうございます!

デフォルトのままだと、googleがうまく sitemapを見つけてくれなかったので、astro純正機能のsitemap機能を追加しました。

cloudflare のビルドログ:

09:19:36.331	λ src/pages/feed.ts
09:19:36.344	  └─ /feed (+33ms)
09:19:36.345	Completed in 147.87s.
09:19:36.345	
09:19:36.507	@astrojs/sitemap: `sitemap-index.xml` is created.
09:19:36.507	
09:19:36.508	12:19:36 AM [build] 161 page(s) built in 165.88s
09:19:36.508	12:19:36 AM [build] Complete!
09:19:36.542	Finished
09:19:36.543	Note: No functions dir at /functions found. Skipping.
09:19:36.543	Validating asset output directory
09:19:37.322	Deploying your site to Cloudflare's global network...
09:19:39.685	Uploading... (50/212)
09:19:40.769	Uploading... (104/212)
09:19:41.805	Uploading... (158/212)
09:19:51.440	Uploading... (212/212)
09:19:51.440	✨ Success! Uploaded 162 files (50 already uploaded) (12.18 sec)
09:19:51.441	
09:19:51.866	✨ Upload complete!
09:19:54.101	Success: Assets published!
09:19:55.501	Success: Your site was deployed!

無事に @astrojs/sitemap 機能のログが表示されました。

さっそく、Google Search Console に登録します。

Image in a image block

無事に Search Console から正常処理のコメントが表示されました。

以下の2ファイルの修正でOK

astro.config.mjs

@ -4,6 +4,7 @@ import CoverImageDownloader from './src/integrations/cover-image-downloader';
import CustomIconDownloader from './src/integrations/custom-icon-downloader';
import FeaturedImageDownloader from './src/integrations/featured-image-downloader';
import PublicNotionCopier from './src/integrations/public-notion-copier';
import sitemap from '@astrojs/sitemap';

const getSite = function () {
  if (CUSTOM_DOMAIN) {
@ -40,5 +41,10 @@ export default defineConfig({
    CustomIconDownloader(),
    FeaturedImageDownloader(),
    PublicNotionCopier(),
    sitemap({
      changefreq: 'daily',
      priority: 0.8,
      lastmod: new Date(),
    }),
  ],
});

package.json

@ -19,6 +19,7 @@
  "dependencies": {
    "@astrojs/react": "^2.2.0",
    "@astrojs/rss": "^2.4.2",
    "@astrojs/sitemap": "^1.1.0",
    "@notionhq/client": "^2.2.5",
    "@supercharge/promise-pool": "^2.4.0",
    "astro": "^2.5.6",

結果として、/sitemap-index.xml ファイルが無事に生成されます。


「上記記事は私が頑張って❓編集しました💗。」
Featured image of the post