bigger_longer
@bigger_longer

Nuxt.js не генерируются мета теги. Что не так?

Nuxt.js

"dependencies": {
    "@nuxtjs/axios": "^5.12.5",
    "@nuxtjs/robots": "^2.4.2",
    "@nuxtjs/sitemap": "^2.4.0",
    "aos": "^2.3.4",
    "axios": "^0.21.1",
    "core-js": "^3.6.5",
    "jquery": "^3.5.1",
    "marked": "^1.2.7",
    "nuxt": "^2.14.0",
    "nuxt-purgecss": "^1.0.0",
    "vue-friendly-iframe": "^0.19.0",
    "vue-lazyload": "^1.3.3",
    "vue-owl-carousel": "^2.0.3",
    "vue-vimeo-player": "^0.1.1"
  },

При генерации проекта при помощи команды npm run generate не генерируются следующие мета теги - title и meta description.

nuxt.config.js
export default {
  head: {
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      { hid: "description", name: "description", content: "" },
      {
        hid: "og:title",
        property: "og:title",
        content: “xxxxx - Rated #1 in Video Ad Service"
      },
      {
        hid: "og:description",
        property: "og:description",
        content:
          “xxx”
      },
      {
        hid: "og:type",
        property: "og:type",
        content: "website"
      },
      {
        hid: "og:image",
        property: "og:image",
        content: "/og-image.png"
      },
      {
        hid: "og:url",
        property: "og:url",
        content: “xxxxx”
      },
      {
        hid: "og:locale",
        property: "og:locale",
        content: "en_GB"
      }
    ],
    link: [
      { rel: "icon", type: "image/x-icon", href: "/favicon.png" },
      {
        rel: "stylesheet",
        href: "/libs/bootstrap/bootstrap-reboot.min.css"
      },
      {
        rel: "stylesheet",
        href: "/libs/bootstrap/bootstrap-grid.min.css"
      },
      // {
      //   rel: "stylesheet",
      //   href: "/libs/owl-carousel/owl.carousel.css"
      // },
      {
        rel: "stylesheet",
        href: "/css/main.css"
      },
      {
        rel: "stylesheet",
        href: "/css/media.css"
      }
    ],
    script: [
      {
        src: "https://code.jquery.com/jquery-1.11.1.min.js"
      },
      {
        src: "/js/common.js"
      },
      {
        src: "/ga.js"
      },
      {
        src: "/pixel.js"
      }
    ]
  },
  target: "static",
  sitemap: {
    hostname: “xxxxxxxxx”,
    path: "/sitemap.xml"
  },

  css: [],

  plugins: [
    { src: "~/plugins/lazy", ssr: false },
    { src: "~/plugins/iframe", ssr: false },
    { src: "~/plugins/aos", ssr: false }
  ],

  components: true,

  buildModules: [],

  modules: ["@nuxtjs/axios", "@nuxtjs/sitemap", "@nuxtjs/robots"],

  build: {}
};

На каждой странице есть конструкция head:

head() {
    return {
      title: ‘xxxxx - Rated #1 in Video Ad Service',
      meta: [
        {
          hid: "description",
          name: "description",
          content:
            “xxxxx”,
        },
      ],
    };
  },

При генерации в html встраиваются нормально только мета теги связанные с open graph (og:), те которые прописаны в nuxt.config.js. Эксперимента ради, убирал все посторонние библиотеки и пробовал генерировать, на удивление все генерится как нужно.

Также если в nuxt.config прописать статический title, при генерации он встраивается нормально в разметку html.

При запуске проекта на сервере title и meta description отрабатывает как нужно, то есть, после загрузки скриптов ставятся нужные теги, но к примеру seo боты не дожидаются загрузки скриптов и не видят этих тегов.
  • Вопрос задан
  • 439 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы