Dont take into account default alternateref and self locale
See original GitHub issuenext-sitemap
dont take into account the default alternate ref and duplicate self locale, included defaultLocale. Here is my configuration:
my next config:
...
i18n: {
locales: [
"en",
"es",
],
defaultLocale: "es",
},
...
My alternateRef:
alternateRefs = [
{
href: process.env.NEXT_PUBLIC_WEB_URL,
hreflang: "es",
},
{
href: process.env.NEXT_PUBLIC_WEB_URL + "/en",
hreflang: "en",
},
];
The generated xml:
...
<url><loc>https://web-test.com/faq</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-06-04T13:17:26.429Z</lastmod><xhtml:link rel="alternate" hreflang="es" href="https://web-test.com/faq"/><xhtml:link rel="alternate" hreflang="en" href="https://web-test.com/en/faq"/></url>
<url><loc>https://web-test.com/es/faq</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-06-04T13:17:26.429Z</lastmod><xhtml:link rel="alternate" hreflang="es" href="https://web-test.com/es/faq"/><xhtml:link rel="alternate" hreflang="en" href="https://web-test.com/en/es/faq"/></url>
<url><loc>https://web-test.com/en/faq</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-06-04T13:17:26.429Z</lastmod><xhtml:link rel="alternate" hreflang="es" href="https://web-test.com/en/faq"/><xhtml:link rel="alternate" hreflang="en" href="https://web-test.com/en/en/faq"/></url>
...
However on getServerSideProps
I managed it, i leave my configuration there:
export const getServerSideProps = async (ctx) => {
const { data: ports } = await axios.get(getPorts());
const fields = ports.map((port) => {
const endpoint = `/ports/${String(port.ID)}`;
return {
loc: process.env.NEXT_PUBLIC_WEB_URL + endpoint,
lastmod: port.UpdatedAt || new Date().toISOString(),
// changefreq
// priority
alternateRefs: alternateRefs.map((ar) => ({
...ar,
href: ar.href + endpoint,
})),
};
});
return getServerSideSitemap(ctx, fields);
};
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:9
Top Results From Across the Web
curl: (60) SSL certificate problem: unable to get local issuer ...
If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a...
Read more >Style Sheets in HTML documents - W3C
Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect.
Read more >National Guidelines for Behavioral Health Crisis Care
The National Guidelines for Crisis Care – A Best Practice Toolkit advances national guidelines in crisis care within a toolkit that supports ...
Read more >Test an insecure registry - Docker Documentation
Edit the daemon.json file, whose default location is ... Substitute the address of your insecure registry for the one in the example.
Read more >Deploy an Azure Pipelines agent on Linux - Microsoft Learn
Prepare permissions · Information security for self-hosted agents · Decide which user you'll use · Confirm the user has permission.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @iamvishnusankar
I’m running into the same issue, the locale from the loc is reused to build the alternate link:
May I know why did you close this ticket ? I’m using “^2.5.7” Also this is about the same issue I guess https://github.com/iamvishnusankar/next-sitemap/issues/284.
For now I have applied this workaround Here is my config
And the fix
Thanks!
solution from @gkielwasser fixed the issue for me. Thanx!
@iamvishnusankar I think this patch should be applied to the package.