gpt4 book ai didi

javascript - 如何通知 GoogleBot 关于 Angular SPA 中的 404 页面?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:27:06 25 4
gpt4 key购买 nike

可能是重复的问题 Best way to set up 404 pages in a angular SPA?但我没有为我的问题找到可靠的答案。
我很想知道是否有办法告诉 googlebot 关于 404 页面的信息?为此目的,有一个名为 prerender-status-code 的标签,但我没有找到 Google Seo 团队的任何官方文章来确认他们尊重这个元标签。
这足以遵循 here 中指定的最佳实践吗? ?
还是我应该做更多的事情? (也许与 Google 网站管理员工具有关?)
我对一些知名的 SPA 进行了研究,我注意到 SoundCloud 在他们的 404 页面上添加了一个 nofollow 标签,如下所示:

<meta content="noindex, nofollow" name="robots">

googlebot 是否尊重后来由 js 添加的元标记?

最佳答案

您可以在 404 组件中动态添加元标记:

import { Component } from '@angular/core';
import { Meta } from '@angular/platform-browser';

@Component({
selector: 'app-notfound',
templateUrl: './notfound.component.html',
styleUrls: []
})
export class NotFoundComponent {

constructor(private meta: Meta) {
meta.addTag({ name: "robots", content: "noindex" });
}

Google 在 angular.io 网站上自己做:https://github.com/angular/angular/blob/7b56daffe68c1874ece7ac3b5e252e1edfed980a/aio/src/index.html

关于javascript - 如何通知 GoogleBot 关于 Angular SPA 中的 404 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35989950/

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