๋ฉ”์ธ ์ปจํ…์ธ ๋กœ ์ด๋™
๋ฒ„์ „: 3.6.3

๐Ÿ“ฆ plugin-sitemap

๊ฒ€์ƒ‰ ์—”์ง„ ํฌ๋กค๋Ÿฌ๊ฐ€ ์—ฌ๋Ÿฌ๋ถ„์˜ ์‚ฌ์ดํŠธ๋ฅผ ์ •ํ™•ํ•˜๊ฒŒ ์ˆ˜์ง‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ์‚ฌ์ดํŠธ๋งต์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ์ž…๋‹ˆ๋‹ค.

production only

This plugin is always inactive in development and only active in production because it works on the build output.

Installationโ€‹

npm install --save @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' | nullnulldate is YYYY-MM-DD. datetime is a ISO 8601 datetime. null is disabled. See sitemap docs.
changefreqstring | null'weekly'See sitemap docs
prioritynumber | null0.5See sitemap docs
ignorePatternsstring[][]glob ํŒจํ„ด ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. ์ผ์น˜ํ•˜๋Š” ๋ผ์šฐํŠธ ๊ฒฝ๋กœ๋Š” ์‚ฌ์ดํŠธ๋งต์—์„œ ํ•„ํ„ฐ๋ง๋ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์— base URL์„ ํฌํ•จํ•ด์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
filenamestringsitemap.xml์ถœ๋ ฅ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์ƒ์„ฑ๋œ ์‚ฌ์ดํŠธ๋งต ํŒŒ์ผ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค. ๋‘ ๊ฐœ์˜ ํŒŒ์ผ์„ ์ถœ๋ ฅํ•˜๋Š” ๋‘ ๊ฐœ์˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ์ธ์Šคํ„ด์Šค๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
createSitemapItemsCreateSitemapItemsFn | undefinedundefinedAn 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 generated
  • trailingSlash: determines if the URLs in the sitemap have trailing slashes
About lastmod

The 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โ€‹

ํ”„๋ฆฌ์…‹ ์˜ต์…˜์ด๋‚˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ์˜ต์…˜์—์„œ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŒ

๋Œ€๋ถ€๋ถ„์˜ ๋„ํ์‚ฌ์šฐ๋ฃจ์Šค ์‚ฌ์šฉ์ž๋Š” ํ”„๋ฆฌ์…‹ ์˜ต์…˜์„ ์‚ฌ์šฉํ•ด ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

ํ”„๋ฆฌ์…‹์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ํ”„๋ฆฌ์…‹ ์˜ต์…˜๋ฅผ ํ†ตํ•ด ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

docusaurus.config.js
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/'));
},
},
},
],
],
};

You can find your sitemap at /sitemap.xml.