๐ฆ plugin-sitemap
๊ฒ์ ์์ง ํฌ๋กค๋ฌ๊ฐ ์ฌ๋ฌ๋ถ์ ์ฌ์ดํธ๋ฅผ ์ ํํ๊ฒ ์์งํ ์ ์๋๋ก ์ฌ์ดํธ๋งต์ ๋ง๋ค์ด์ฃผ๋ ํ๋ฌ๊ทธ์ธ์ ๋๋ค.
This plugin is always inactive in development and only active in production because it works on the build output.
Installationโ
- npm
 - Yarn
 - pnpm
 - Bun
 
npm install --save @docusaurus/plugin-sitemap
yarn add @docusaurus/plugin-sitemap
pnpm add @docusaurus/plugin-sitemap
bun add @docusaurus/plugin-sitemap
If you use the preset @docusaurus/preset-classic, you don't need to install this plugin as a dependency.
You can configure this plugin through the preset options.
Configurationโ
์ค์ ํ ์ ์๋ ํ๋
| ์ต์ ๋ช | ํ์ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช | 
|---|---|---|---|
lastmod | 'date' | 'datetime' | null | null | date is YYYY-MM-DD. datetime is a ISO 8601 datetime. null is disabled. See sitemap docs. | 
changefreq | string | null | 'weekly' | See sitemap docs | 
priority | number | null | 0.5 | See sitemap docs | 
ignorePatterns | string[] | [] | glob ํจํด ๋ชฉ๋ก์ ๋๋ค. ์ผ์นํ๋ ๋ผ์ฐํธ ๊ฒฝ๋ก๋ ์ฌ์ดํธ๋งต์์ ํํฐ๋ง๋ฉ๋๋ค. ์ฌ๊ธฐ์ base URL์ ํฌํจํด์ผ ํ ์๋ ์์ต๋๋ค. | 
filename | string | sitemap.xml | ์ถ๋ ฅ ๋๋ ํ ๋ฆฌ๋ฅผ ๊ธฐ์ค์ผ๋ก ์์ฑ๋ ์ฌ์ดํธ๋งต ํ์ผ ๊ฒฝ๋ก์ ๋๋ค. ๋ ๊ฐ์ ํ์ผ์ ์ถ๋ ฅํ๋ ๋ ๊ฐ์ ํ๋ฌ๊ทธ์ธ ์ธ์คํด์ค๊ฐ ์๋ ๊ฒฝ์ฐ ์ ์ฉํฉ๋๋ค. | 
createSitemapItems | CreateSitemapItemsFn | undefined | undefined | An optional function which can be used to transform and / or filter the items in the sitemap. | 
Typesโ
CreateSitemapItemsFnโ
type CreateSitemapItemsFn = (params: {
  siteConfig: DocusaurusConfig;
  routes: RouteConfig[];
  defaultCreateSitemapItems: CreateSitemapItemsFn;
}) => Promise<SitemapItem[]>;
์ด ํ๋ฌ๊ทธ์ธ์ ์ผ๋ถ ์ฌ์ดํธ ์ค์ ์ ์ ์งํฉ๋๋ค.
noIndex: results in no sitemap generatedtrailingSlash: determines if the URLs in the sitemap have trailing slashes
lastmodThe lastmod option will only output a sitemap <lastmod> tag if plugins provide route metadata attributes sourceFilePath and/or lastUpdatedAt.
All the official content plugins provide the metadata for routes backed by a content file (Markdown, MDX or React page components), but it is possible third-party plugin authors do not provide this information, and the plugin will not be able to output a <lastmod> tag for their routes.
Example configurationโ
ํ๋ฆฌ์  ์ต์ ์ด๋ ํ๋ฌ๊ทธ์ธ ์ต์ ์์ ํ๋ฌ๊ทธ์ธ์ ์ค์ ํ ์ ์์ต๋๋ค.
๋๋ถ๋ถ์ ๋ํ์ฌ์ฐ๋ฃจ์ค ์ฌ์ฉ์๋ ํ๋ฆฌ์  ์ต์ ์ ์ฌ์ฉํด ํ๋ฌ๊ทธ์ธ์ ์ค์ ํฉ๋๋ค.
- ํ๋ฆฌ์  ์ต์ 
 - ํ๋ฌ๊ทธ์ธ ์ต์ 
 
ํ๋ฆฌ์ ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ํ๋ฆฌ์  ์ต์ ๋ฅผ ํตํด ํ๋ฌ๊ทธ์ธ์ ๊ตฌ์ฑํฉ๋๋ค.
module.exports = {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        sitemap: {
          lastmod: 'date',
          changefreq: 'weekly',
          priority: 0.5,
          ignorePatterns: ['/tags/**'],
          filename: 'sitemap.xml',
          createSitemapItems: async (params) => {
            const {defaultCreateSitemapItems, ...rest} = params;
            const items = await defaultCreateSitemapItems(rest);
            return items.filter((item) => !item.url.includes('/page/'));
          },
        },
      },
    ],
  ],
};
๋ ๋ฆฝ์ ์ผ๋ก ์คํ๋๋ ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์๋ ํ๋ฌ๊ทธ์ธ์ ๋ํ ์ต์ ์ ์ง์  ์ค์ ํ ์ ์์ต๋๋ค.
module.exports = {
  plugins: [
    [
      '@docusaurus/plugin-sitemap',
      {
        lastmod: 'date',
        changefreq: 'weekly',
        priority: 0.5,
        ignorePatterns: ['/tags/**'],
        filename: 'sitemap.xml',
        createSitemapItems: async (params) => {
          const {defaultCreateSitemapItems, ...rest} = params;
          const items = await defaultCreateSitemapItems(rest);
          return items.filter((item) => !item.url.includes('/page/'));
        },
      },
    ],
  ],
};
You can find your sitemap at /sitemap.xml.