Improving SEO with Vue-Meta

A Powerful Library to Boost Visibility and Rankings in Your Vue App

Improving SEO with Vue-Meta

Welcome to the second part of the two-part series, Improving SEO: A Tale of Two Libraries. Search Engine Optimization (SEO) is paramount in getting your website noticed in the competitive landscape of the internet. Optimizing your website for search engines not only increases visibility but also drives organic traffic. However, improving SEO in Single Page Applications (SPAs), like those built with Vue, can be particularly challenging due to their dynamic nature. Vue-Meta is a great tool that can help to overcome these challenges.

What is Vue-Meta?

Vue-Meta is a JavaScript library that enables you to dynamically manage the content of the document head. To put it simply, it gives you the ability to manage the <head> of your HTML document in Vue apps. Because search engines like Google significantly rely on the data in the <head> section to comprehend and rank your web pages, this control is crucial for SEO.

Why Vue-Meta for SEO?

Vue-Meta provides a robust toolkit for optimizing your website's SEO performance. It offers a wide range of features related to SEO, and in this section, we'll focus on the following key aspects:

  • Title and Meta Tags - The Foundation of SEO: Proper management of title and meta tags is fundamental in SEO. These tags are a vital component of any SEO plan because they serve as the first link between your site and search engines. Vue-Meta gives you the ability to dynamically set and change title tags for each page in your Vue app.

  • Open Graph and Twitter Cards: When users share content on social media platforms, they expect it to look good. Open Graph and Twitter Card metadata allow you to define the image, name, and description that appears in social media preview formats. With Vue-Meta, you can set up metadata for Open Graph and Twitter Cards for each page in your Vue app.

Setting Up Vue-Meta

Installation

Start by installing vue-meta using npm or yarn.

npm install vue-meta
# or
yarn add vue-meta

Integration with Vue Application

In your main.js or the entry point file for your Vue application:

import Vue from 'vue';
import VueMeta from 'vue-meta';
import App from './App.vue'; 

Vue.use(VueMeta);

new Vue({
  render: (h) => h(App),
}).$mount('#app');

Using Vue-Meta Across Different Pages

Now that vue-meta is up and running, let’s take a closer look at how it can be used across different pages of your app.

Updating Tags, Titles, and Descriptions

Within your component, vue-meta can be used to set and update different document head elements. For example, you can set and update the following title and meta description:

<template>
  <main>
     <h1>This is the home page 🏡 </h1>
  </main>
</template>

<script>
    export default {
      metaInfo: {
        title: 'Home Page Title',
        meta: [
          {
            name: 'description',
            content: 'This is the home page description.',
          },
        ],
      },
    };
  </script>

Implementing Open Graph and Twitter Cards

You can add specific metadata tags to create Open Graph and Twitter Cards with Vue-Meta:

<template>
  <main>
     <h1>This is the about page 🕵🏾‍♀️ </h1>
  </main>
</template>

<script>
    export default {
      metaInfo: {
        meta: [
          {
            property: 'og:title',
            content: 'About Page Title',
          },
          {
            property: 'og:description',
            content: 'This is the about page description.',
          },
          {
            property: 'og:image',
            content: 'https://example.com/about-page-image.jpg',
          },
          {
            name: 'twitter:card',
            content: 'summary_large_image',
          },
          {
            name: 'twitter:title',
            content: 'About Page Title',
          },
          {
            name: 'twitter:description',
            content: 'This is the about page description.',
          },
          {
            name: 'twitter:image',
            content: 'https://example.com/about-page-image.jpg',
          },
        ],
      },
    };
  </script>

It’s important to test and troubleshoot after you’ve implemented vue-meta. You can do this using browser developer tools and SEO testing tools to make sure your metadata is set correctly.

Conclusion

Vue-Meta is an effective solution for managing the document head of your Vue app. You can manage titles, descriptions, Open Graph, and Twitter Cards by effectively utilising it across many pages, which will improve your SEO and social media presence through improved content sharing on social platforms.

Thank you for reading and I hope you found this post helpful. 💫