我试图在谷歌搜索控制台添加一个站点地图。
我有这样的代码:
路由
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>
但是当我试图将站点地图添加到google时,它说sitemap不能是html格式。
我如何使它有效的谷歌搜索控制台?
发布于 2018-02-27 02:36:33
溶液
var path = require("path");
router.get('/sitemap.xml', function(req, res) {
res.sendFile(path.join(__dirname, 'path', 'sitemap.xml'));
});
https://stackoverflow.com/questions/48998711
复制相似问题