mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What? Following up with [this suggestion](https://github.com/vercel/next.js/discussions/53540) I went ahead and implemented the proposal for the Next.js team to merge it if they agree. Things to keep in mind: - Google has [three different ways](https://developers.google.com/search/docs/specialty/international/localized-versions#methods-for-indicating-your-alternate-pages) to do this. The three of them are equivalent - Google seems to be the only search engine supporting this approach. The rest of them should ignore it ### Why? This is supported by [Google](https://developers.google.com/search/docs/specialty/international/localized-versions#example_2) to better understand the site when the same page is available in multiple languages. ### How? - I added a new key to the `MetadataRoute.Sitemap` type called `alternates` which accepts just one sub key `languages` similar to the current one in the [Metadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#alternates) object - I updated the `resolveSitemap` method to process the new key and generate the expected sitemap - I updated the related tests and documentation to reflect the new syntax --------- Co-authored-by: Jiachi Liu <[email protected]>
23 lines
488 B
TypeScript
23 lines
488 B
TypeScript
import { MetadataRoute } from 'next'
|
|
|
|
export default function sitemap(): MetadataRoute.Sitemap {
|
|
return [
|
|
{
|
|
url: 'https://example.com',
|
|
lastModified: '2021-01-01',
|
|
changeFrequency: 'daily',
|
|
priority: 0.5,
|
|
},
|
|
{
|
|
url: 'https://example.com/about',
|
|
lastModified: '2021-01-01',
|
|
alternates: {
|
|
languages: {
|
|
es: 'https://example.com/es/about',
|
|
de: 'https://example.com/de/about',
|
|
},
|
|
},
|
|
},
|
|
]
|
|
}
|