I am using Strapi, it is pulled in JSON format.
Example of what a regular website link looks like: https:/ /www.some-site.com/some-link
What happens to my links after post build is done on my Nextjs project:
<url><loc>https://website-name.com/en/something-links</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-10-12T05:43:36.829Z</lastmod></url>
Now if you'll notice, the language (/en/) shows up on the link. I have created a next-sitemap.js file to try and remove this issue but it is not working.
Here is what the code in next-sitemap.js looks like:
next-sitemap.js
const defaultRegion = 'us';
module.exports = {
siteUrl: process.env.NEXT_PUBLIC_SITE_URL,
generateRobotsTxt: false,
sitemapSize: 7000,
transform: async (config, path) => {
const defaultLocalePath = `/${defaultRegion}/`;
let transformedPath = path;
if (path.substring(0, defaultLocalePath.length) === defaultLocalePath) {
transformedPath = path.substring(defaultLocalePath.length, path.length);
}
return {
loc: transformedPath,
changefreq: config.changefreq,
priority: config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? [],
};
},
};
I have over 200+ links and pages on my website.
I am receiving an error in the first line itself