-
This commit is contained in:
+13
-11
@@ -31,11 +31,10 @@ function generate() {
|
||||
const sitemapFiles = [];
|
||||
let totalIndexedUrls = 0;
|
||||
|
||||
// 1. 공통 및 메인 대표 랜딩 페이지 사이트맵 (sitemap-main.xml)
|
||||
// 1. 공통 및 메인 대표 페이지 사이트맵 (sitemap-main.xml - 지역 사이트맵과 중복되지 않는 고유 URL만 수록)
|
||||
const mainUrls = [
|
||||
{ loc: `${SITE_ORIGIN}`, priority: '1.0', changefreq: 'daily' },
|
||||
{ loc: `${SITE_ORIGIN}/regions`, priority: '0.9', changefreq: 'daily' },
|
||||
{ loc: `${SITE_ORIGIN}${DEFAULT_PATH}`, priority: '1.0', changefreq: 'daily' }
|
||||
{ loc: `${SITE_ORIGIN}/regions`, priority: '0.9', changefreq: 'daily' }
|
||||
];
|
||||
const mainXml = generateUrlXml(mainUrls, today);
|
||||
fs.writeFileSync(path.join(publicDir, 'sitemap-main.xml'), mainXml, 'utf-8');
|
||||
@@ -81,14 +80,17 @@ ${sitemapFiles
|
||||
`;
|
||||
fs.writeFileSync(path.join(publicDir, 'sitemap.xml'), indexXml, 'utf-8');
|
||||
|
||||
// 4. robots.txt
|
||||
const robots = `User-agent: *
|
||||
Allow: /
|
||||
Disallow: /admin
|
||||
Disallow: /regions/admin
|
||||
|
||||
Sitemap: ${SITE_ORIGIN}/sitemap.xml
|
||||
`;
|
||||
// 4. robots.txt (루트 사이트맵 인덱스 및 시·도별 분할 사이트맵 전체 명시)
|
||||
const robots = [
|
||||
'User-agent: *',
|
||||
'Allow: /',
|
||||
'Disallow: /admin',
|
||||
'Disallow: /regions/admin',
|
||||
'',
|
||||
`Sitemap: ${SITE_ORIGIN}/sitemap.xml`,
|
||||
...sitemapFiles.map((file) => `Sitemap: ${SITE_ORIGIN}/${file}`),
|
||||
''
|
||||
].join('\n');
|
||||
fs.writeFileSync(path.join(publicDir, 'robots.txt'), robots, 'utf-8');
|
||||
|
||||
console.log(`[OK] 사이트맵 인덱스(sitemap.xml) 및 ${sitemapFiles.length}개 시·도 분할 사이트맵 생성 완료!`);
|
||||
|
||||
Reference in New Issue
Block a user