我意识到这个问题的例子不够详细,但我确实从 prerender.io 知识库中找到了解决问题的方法
2018 年 5 月,Google 推出了“动态渲染”,用于向您的用户提供普通 JavaScript 并向搜索引擎提供预渲染页面。这正是我们在 Prerender.io 所做的。
Google 为动态呈现引入的更改意味着他们将停止抓取 ?escaped_fragment= 网址,您现在可以通过直接检查其用户代理将预呈现的页面提供给 Googlebot。这听起来像是在伪装,但 Google 引入了一项政策更改,允许您通过检查其用户代理将预呈现的页面发送到 Googlebot。
由于此动态渲染公告,我们更改了中间件,将 Googlebot 添加到直接检查的用户代理列表中。
查看 useragent.py 文件时所说的
# These first three should be disabled, since they support escaped
fragments, and
# and leaving them enabled will penalize a website as "cloaked".
# "Googlebot",
# "Yahoo",
# "bingbot",
Googlebot 仍然在 django-seo-js 中被注释掉,为了解决这个问题,我不得不在 settings.py 中手动将它添加到列表中
SEO_JS_USER_AGENTS=(
"Googlebot",
# "Yahoo",
# "bingbot",
"Ask Jeeves",
"baiduspider",
"facebookexternalhit",
"twitterbot",
"rogerbot",
"linkedinbot",
"embedly",
"quoralink preview'",
"showyoubot",
"outbrain",
"pinterest",
"developersgoogle.com/+/web/snippet",
)
由于变量值未附加到现有列表中,我们必须将它们全部添加。