按语言分类的动态站点地图

Dynamic sitemap by language

我有几个静态站点地图(一个站点地图用于一种语言,即 sitemap_en.xml、sitemap_de.xml),我想要一个最终的静态站点地图 sitemap.xml(http://example.com/sitemap.xml) which targets good sitemap depending on language (http://example.de/sitemap.xml - -> sitemap_de.xml)

我想知道如何在 React 应用程序中以 ssr 方式做到这一点

app.get('/sitemap.xml', function(req, res) {
  res.sendFile('good_path_to_correct_sitemap.xml');
});

也许有更好的解决方案来处理多域多语言网站中的多个静态站点地图

您需要将所有站点地图集中到一个站点地图中index,引用:

If you have many sitemaps, you can use a sitemaps index file as a way to submit them at once. The XML format of a sitemap index file is very similar to the XML format of a sitemap file.

但在你的情况下,由于每种语言都在不同的域中提供,你可以做一个 cross submit,引用:

By default, this will result in a "cross submission" error since you are trying to submit URLs for www.host1.com through a Sitemap that is hosted on www.sitemaphost.com (and same for the other two hosts). One way to avoid the error is to prove that you own (i.e. have the authority to modify files) www.host1.com. You can do this by modifying the robots.txt file on www.host1.com to point to the Sitemap on www.sitemaphost.com.