我正在开发一个网站,后端为 django,前端为 jquery。
当调用列表/详细信息页面 url 时,我将在页面加载时调用 ajax 方法并从后端呈现数据。支持的结果由 django 序列化为 json 数据并呈现回 ajax。
例如:
function listFunction(){
$.ajax({
url: '<listing-url>',
type: 'GET',
dataType: 'json',
})
.done(function(response){
// response as json
$.each(response, function(index, value){
$(container).append(value)
});
});
}
$(document).ready(function(e){
listFunction();
});
为了检查我的网站如何被 google 看到,我在 google 搜索控制台 中测试了我的列表页面:
https://www.google.com/webmasters/verification/home?hl=en
我在 Fetch as Google 标签中使用了 Fetch and Render 选项。结果中只加载了页眉、页脚等静态内容,没有显示通过 ajax 加载的动态内容。我已经为网站创建了站点地图和robots.txt。
Seo 对我们的项目非常重要。如何在使用 Fetch as Google 时显示我的动态内容?
如果我在编码部分遗漏了什么,请告诉我。
谢谢。
最佳答案
来自 documentation ,这表明您的页面代码存在问题,因为 Fetch 和 Render 确实执行脚本。
Google Search Console 能够抓取网站,因为显示的是静态内容。您的问题与 robots.txt 或站点地图无关。
关于jquery - 无法使用 Google Search Console 抓取我的新网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48516839/