B
B
bigger longer2021-01-20 17:57:38
Search Engine Optimization
bigger longer, 2021-01-20 17:57:38

Nuxt.js does not generate meta tags. What's wrong?

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"
  },

When generating a project using the command npm run generate, the following meta tags are not generated - title and 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: {}
};

Each page has a head construct:

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

When generating in html, only meta tags related to open graph (og :) are normally embedded, those that are registered in nuxt.config.js. For the sake of experiment, I removed all extraneous libraries and tried to generate, surprisingly everything is generated as it should.

Also, if you specify a static title in nuxt.config, it is embedded normally in the html markup when generated.

When the project is launched on the server, the title and meta description work out as needed, that is, after the scripts are loaded, the necessary tags are put, but for example, seo bots do not wait for the scripts to load and do not see these tags.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question