如何在 Blazor WASM 应用程序中生成 sitemap.xml 文件

sro*_*e98 6 blazor-client-side blazor-webassembly

我目前正在使用 Blazor WASM 应用程序来托管网站和博客。添加Google Tag Manager不是问题,但一直困扰我的是如何添加可以动态生成的sitemap.xml。有人有这样做的经验吗?

小智 0

我有一个解决方法。在 Blazor WebAssembly 项目的wwwroot文件夹中添加sitemap.xml

示例sitemap.xml代码:

<?xml version="1.0" encoding="utf-8" ?>
<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:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
  <url>
    <loc>https://demos.getblazorbootstrap.com</loc>
    <changefreq>daily</changefreq>
    <priority>0.9</priority>
  </url>
</urlset>
Run Code Online (Sandbox Code Playgroud)

有关 sitemap.xml 结构的更多信息,请参阅 sitemap.org。