We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next 使用 next-sitemap
生成 sitemaps 索引,在大文件拆分应该可以用到
// pages/server-sitemap-index.xml/index.tsx import { getServerSideSitemapIndex } from 'next-sitemap' import { GetServerSideProps } from 'next' export const getServerSideProps: GetServerSideProps = async (ctx) => { // Method to source urls from cms // const urls = await fetch('https//example.com/api') return getServerSideSitemapIndex(ctx, [ 'https://example.com/path-1.xml', 'https://example.com/path-2.xml', ]) } // Default export to prevent next.js errors export default function SitemapIndex() {}
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>https://example.com/path-1.xml</loc> </sitemap> <sitemap> </sitemapindex>
生成 sitemaps
// pages/server-sitemap.xml/index.tsx import { getServerSideSitemap } from 'next-sitemap' import { GetServerSideProps } from 'next' export const getServerSideProps: GetServerSideProps = async (ctx) => { // Method to source urls from cms // const urls = await fetch('https//example.com/api') const fields = [ { loc: 'https://example.com', // Absolute url lastmod: new Date().toISOString(), // changefreq // priority }, { loc: 'https://example.com/dynamic-path-2', // Absolute url lastmod: new Date().toISOString(), // changefreq // priority }, ] return getServerSideSitemap(ctx, fields) } // Default export to prevent next.js errors export default function Sitemap() {}
fields TS is ISitemapField[]
fields
ISitemapField[]
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"> <url> <loc>https://demo.io/game/65</loc> <lastmod>2022-05-12T16:35:07.696Z</lastmod> <changefreq>daily</changefreq> <priority>0.7</priority> </url> </urlset>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Next 使用 next-sitemap
Server side index-sitemaps (getServerSideSitemapIndex)
生成 sitemaps 索引,在大文件拆分应该可以用到
server side sitemap (getServerSideSitemap)
生成 sitemaps
fields
TS isISitemapField[]
JSON-LD
The text was updated successfully, but these errors were encountered: