【发布时间】:2021-09-02 14:19:12
【问题描述】:
我的问题类似于this,除了我没有收到任何错误。 我添加的标题在选项卡上可见,当我检查页面时可以看到元标记。但在查看页面源代码中,标题和元标记均不可见。如何使它们在 View Page Source 中也可见?
我已经预渲染了我的网站。
我正在使用的代码:
import { Component, OnInit } from '@angular/core';
import { Meta, Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
@Component({
selector: 'app-some',
templateUrl: './some.component.html',
styleUrls: ['./some.component.css'],
})
export class HighlightsComponent implements OnInit {
constructor(
private router: Router,
private titleService: Title,
private metaService: Meta
) {}
title = 'Some Title';
ngOnInit(): void {
this.titleService.setTitle(this.title);
this.metaService.addTags([
{ name: 'robots', content: 'index, follow' },
]);
}
}
【问题讨论】:
标签: angular seo angular-services angular-universal angular-seo