【问题标题】:Meta data keeps showing as "## Build Setup" for every page in Vuejs/Nuxt?对于 Vuejs/Nuxt 中的每个页面,元数据一直显示为“## Build Setup”?
【发布时间】:2022-12-15 06:25:47
【问题描述】:

我已经在 Nuxt 文档之后的每个页面中添加了单独的元数据,但是每当我在社交媒体上分享我的链接时,元数据只会显示这个“## build setup”。另一个问题是每个页面都显示相同的元数据。我读到您需要放置“hids”才能拥有单独的页面元数据,但似乎没有任何效果?

索引元:

<script>
export default {
  head: {
    title: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing',
    meta: [
      { property: 'og:description', hid: 'og:description', name: 'og:description', content: 'Vote monthly in Animal Crossing Tier Lists for New Horizons & Pocket Camp! Including Villager Tier Lists, Sanrio, Gyroids & more at Animal Crossing Portal!' },
      { name: 'twitter:title', hid: 'twitter:title', content: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing' },
      { name: 'twitter:description', hid: 'twitter:description', content: 'Vote monthly in Animal Crossing Tier Lists for New Horizons & Pocket Camp! Including Villager Tier Lists, Sanrio, Gyroids & more at Animal Crossing Portal!' },
      { name: 'twitter:card', hid: 'twitter:card', content: 'summary_large_image' },
      { name: 'twitter:image:src', hid: 'twitter:image:src', content: 'https://www.animalcrossingportal.com/images/meta.jpg' },
      { property: 'og:title', hid: 'og:title', name: 'og:title', content: 'Animal Crossing Portal | The Best Tier Lists for Animal Crossing' },
      { property: 'og:type', hid: 'og:type', content: 'website' },
      { property: 'og:site_name', hid: 'og:site_name', content: 'Animal Crossing Portal' },
      { property: 'og:url', hid: 'og:url', content: 'https://www.animalcrossingportal.com/' },
      { property: 'og:image', hid: 'og:image', content: 'https://www.animalcrossingportal.com/images/meta.jpg' }
    ],
    link: [
      {
        rel: 'canonical',
        href: 'https://www.animalcrossingportal.com/'
      }
    ]
  }
}
</script>

我的 nuxt.config.js 文件有:

head: {
    meta: [
      { name: 'viewport', content: 'width=device-width, initial-scale=1' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  }

【问题讨论】:

  • 您是否在项目中搜索了build setup?你那里有类似的东西吗?
  • 嘿 kissu 谢谢你的回复,这是我的第一个想法。不幸的是,我的代码中没有任何内容
  • 有那个的公共回购协议吗?
  • 哦,实际上,有一个例子让我失去了控制!我正在搜索所有文件并在自述文件中找到它。当时什么都没想,因为我认为这只是一个读我!我删除了它,现在可以使用了。非常感谢!

标签: node.js vue.js nuxt.js metadata


【解决方案1】:

元数据实际上位于 README.md 文件中,将其从那里移除已解决 OP 的问题!

【讨论】:

    【解决方案2】:

    我以为这是自述文件,但经过几个小时的挖掘(问题重新浮出水面),事实证明它实际上是 nuxt 配置文件中的一个空构建标签,它让 Nuxt 尝试 SSR。删除空标签 100% 修复了它。

    【讨论】:

    • 我遇到了同样的问题,但在我的 nuxt 配置文件中找不到一个空的构建标签:你还记得你的错误配置是什么样的吗?
    【解决方案3】:

    我最近遇到了同样的问题。查看渲染页面的源代码视图(浏览器中的 Ctrl+U)后,快速搜索发现元字段“og:description”未正确填充。对此的更正很简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-30
      • 2022-01-21
      • 1970-01-01
      • 2021-06-12
      • 1970-01-01
      • 2021-07-27
      • 2012-11-21
      • 1970-01-01
      相关资源
      最近更新 更多