seo
Opened this issue · 0 comments
xiaotiandada commented
- https://search.google.com/search-console/about
- https://analytics.google.com/analytics/web/
- https://ziyuan.baidu.com/linksubmit/url?sitename=
- https://tongji.baidu.com/web/welcome/login
- w3itch-crafter/w3itch-frontend#129
- google search console 终极教程
- 关于Robots.txt和SEO: 你所需要知道的一切
- https://github.com/iamvishnusankar/next-sitemap#building-sitemaps
Next 使用 next-sitemap
Server side index-sitemaps (getServerSideSitemapIndex)
生成 sitemaps 索引,在大文件拆分应该可以用到
- https://github.com/iamvishnusankar/next-sitemap#server-side-index-sitemaps-getserversidesitemapindex
// 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>
server side sitemap (getServerSideSitemap)
生成 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[]
<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>