Reputation: 67
Im trying to add a sitemap at Google Search Console.
I have this code:
Route
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>
But when i try to add the sitemap to google it says that the sitemap cant be in html format.
How can i make it valid to Google Search Console?
Upvotes: 0
Views: 618
Reputation: 67
Solution
var path = require("path");
router.get('/sitemap.xml', function(req, res) {
res.sendFile(path.join(__dirname, 'path', 'sitemap.xml'));
});
Upvotes: 1