Nuxt.js SEO Head Component: How To Implement

Build SEO Head tags component in the Nuxt.js website to support HTML Meta tags and JSON schemas

Code Road
Geek Culture
4 min readOct 7, 2022

--

SEO Search Engine Optimization illustration
Photo by Merakist on Unsplash

Nuxt.js has a feature to support customizable HTML Head tags, these include title, description, image, links, canonical, and other meta head tags.

To support SEO-friendly Head tags, we can just put all the necessary items into a component and import it as a default SEO Head component to use in any Nuxt.js pages. The head() will return any HTML Head tags that are defined in the returning objects.

The head() feature from Nuxt.js to support HTML meta tags for SEO
The head() feature from Nuxt.js to support HTML meta tags for SEO

Since some other HTML Head tags are needed to support SEO and most of them have similarities to the content such as Open Graph or Twitter tags, we can put this into one component that supports all of them.

HTML Meta tags for SEO
HTML Meta tags for SEO

Now we can see the similarity in the Meta tags that we can put on one dedicated component in Nuxt.js and name it ./components/SeoHead.vue

After that, we can put all the necessary SEO Meta Tags and JSON Schemas to support the SEO requirements.

Of course, these HTML Head tags can be customized based on your Nuxt.js whether each or one of the JSON schemas is needed for the project requirement.

SeoHead.vue component in Nuxt.js
SeoHead.vue component in Nuxt.js

After that, now we can import the SeoHead.vue component into our layout and pages.

SeoHead.vue component in Nuxt.js layout
SeoHead.vue component in Nuxt.js layout

And here is an example of how to put the SeoHead.vue on the Nuxt.js pages:

SeoHead.vue on Nuxt.js pages
SeoHead.vue on Nuxt.js pages

This is a sample of how we can use just one component to handle all the SEO Head tags on the pages of a Nuxt.js project base, and give you ideas on how you are going to implement these on your Nuxt.js project.

The SeoHead.vue component on ./layout/default.vue will be the default SEO tags if there are no SeoHead.vue component in the Nuxt.js pages.

Here is the source code from the example above, and here is the demo on SEO tags and JSON schemas on Nuxt.js website. And you can read about the process here in my other writing about Chart.js in Nuxt.js: How To Implement.

Closing

All the features from Nuxt.js are very handy and helpful for your website SEO lists, so you do not have to write your own function that probably does the same way you wanted. Just have to read and understand how the modules work and implement them adaptively on your project.

Please do follow me to get more tips and tricks from web development, thank you!

--

--

Code Road
Geek Culture

I write topics such as React/NextJS, Vue/NuxtJS, GraphQL, Laravel, TailwindCSS, Bootstrap, SEO, Headless CMS, Fullstack, and web development.