gpt4 book ai didi

javascript - 谷歌控制台 Node 中的站点地图 xml

转载 作者:行者123 更新时间:2023-12-03 02:24:45 25 4
gpt4 key购买 nike

我正在尝试在 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>

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

如何使其对 Google Search Console 有效?

最佳答案

解决方案

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

关于javascript - 谷歌控制台 Node 中的站点地图 xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48998711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com