Try   HackMD

Nuxt加入sitemap教學手冊

sitemap 提供網站資訊進而增加SEO,提高網站被搜尋引擎找到的機率。

  1. 安裝 nuxt-simple-sitemap
npm i -D nuxt-simple-sitemap
  1. 開啟根目錄 nuxt.config.js,增加以下區塊。
    nuxt.config.js
export default defineNuxtConfig({ modules: [ 'nuxt-simple-sitemap' ] });

2-1 定義標準網址

export default defineNuxtConfig({ ..., site: { url: 'http://xxx.com' } });

2-2 如果要查看xml原始樣子,可加入以下。

export default defineNuxtConfig({ ..., sitemap: { xsl: false } });
  1. 網址鍵入http://xxx.com/sitemap.xml可看到設定結果。
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

添加連結至網站地圖(sitemap)

使用routeRules

export default defineNuxtConfig({ ..., routeRules: { '/school/1': { index: true } }, })

移除連結

使用exclude可排除不要的連結

export default defineNuxtConfig({ ..., sitemap: { exclude: [ '/example/xx', ] } })