【问题标题】:Sitemap xml in node for google console谷歌控制台节点中的站点地图 xml
【发布时间】:2018-02-26 23:22:10
【问题描述】:

我正在尝试在 Google Search Console 中添加站点地图。

我有这个代码:

路线

router.get("/sitemap", function(req, res){
   res.render("sitemap.ejs");
});

Sitemap.ejs

<html>
<head>
    <title>Sitemap</title>
    <link rel="alternate" type="application/rss+xml" title="" href="sitemap.xml" />
</head>
<body>

</body>
</html>

但是当我尝试将站点地图添加到谷歌时,它说站点地图不能是 html 格式。

如何使它对 Google Search Console 有效?

【问题讨论】:

    标签: javascript node.js xml sitemap


    【解决方案1】:

    解决方案

    var path = require("path");
    router.get('/sitemap.xml', function(req, res) {
      res.sendFile(path.join(__dirname, 'path', 'sitemap.xml'));
    });
    

    【讨论】:

      猜你喜欢
      • 2016-01-04
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 2020-09-02
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多