使用 vue-head 和 prerender-spa-plugin 会导致标题和元标记在 netlify 上显示两次 [英] using vue-head with prerender-spa-plugin is causing title and meta tags to be displayed twice on netlify

查看:83
本文介绍了使用 vue-head 和 prerender-spa-plugin 会导致标题和元标记在 netlify 上显示两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题仅在 netlify 上直播时发生(尽管它们的预渲染选项已关闭),而不是在本地提供时发生.

This issue only happens when live on netlify ( despite their prerender option turned off ), not while being served locally.

现场直播:

<title>about | anonplayer about | anonplayer</title>

title 和 meta 标签像这样使用 vue-head 包设置

title and meta tags are set using the vue-head package like so

  head: {  
    title: {
      inner: "about | anonplayer",
      separator: ' ',
    }, ...

这发生在我的单页应用程序的所有路由上,也发生在我打算拥有两组标签的元标签上.

and this happens for all routes of my single page app and also to meta tags where there are two sets of the tags I intended to have.

看起来像这个

我使用了默认的预渲染设置,如下所示:

I used the default prerender settings like so:

  config.plugins.push(new PrerenderSPAPlugin({
    // Required - The path to the webpack-outputted app to prerender.
    staticDir: path.join(__dirname, 'dist'),
    // Required - Routes to render.
    routes: ['/', '/about'].concat(contracts.map(each => `/${each.abi}/${each.contract}`)),
  }))

推荐答案

是一样的,但使用了 Angular

was the same, but with Angular

在我的例子中帮助将 function this.meta.addTag() 替换为 this.meta.updateTag()

in my case helped replacing function this.meta.addTag() with this.meta.updateTag()

所以认为这不是托管问题)

so think it's not hosting issue)

这篇关于使用 vue-head 和 prerender-spa-plugin 会导致标题和元标记在 netlify 上显示两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆