개발자
next-sitemap 라이브러리를 사용해서 sitemap.xml을 만들고 있습니다. 사이트맵이 pages의 static한 폴더 기반으로 생성되는건 확인했는데, dynamic path를 적용한 폴더들은 sitemap에 등록되지 않습니다. 별도로 path를 지정하는 방법이 있을까요?
답변 1
dynamic path를 적용한 곳은 어떤 path가 올지 몰라서 사이트맵을 디폴트로 만들지 않는 것 같습니다. next-sitemap (https://www.npmjs.com/package/next-sitemap) npm docs를 보면 additionalPaths에 대한 설명이 있는데 이 props를 사용하면 될 것 같아요! // Default transformation function transform: async (config, path) => { return { loc: path, // => this will be exported as http(s)://<config.siteUrl>/<path> changefreq: config.changefreq, priority: config.priority, lastmod: config.autoLastmod ? new Date().toISOString() : undefined, alternateRefs: config.alternateRefs ?? [], } }, additionalPaths: async (config) => [ await config.transform(config, '/additional-page'), ],
익명
작성자
2022년 10월 31일
additionalPaths <- 덕분에 이 값 이용해서 직접 추가했습니다! 감사합니다!
지금 가입하면 모든 질문의 답변을 볼 수 있어요!
현직자들의 명쾌한 답변을 얻을 수 있어요.
이미 회원이신가요?
지금 가입하면 모든 질문의 답변을 볼 수 있어요!