Nuxt.js: Declaring language in HTML tag

Created on 15 Mar 2017  路  8Comments  路  Source: nuxt/nuxt.js

Since we can set some meta tags in the head in nuxtConfig file, how do we declare html lang attribute in HTML tag like this ?

<html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">

This question is available on Nuxt.js community (#c338)

Most helpful comment

you can edit in nuxt.config.js

module.exports = {
  /**
   * if you want after run npm generate place dist to subdomain on webhost , you should change base 
   */
  router: {
    base: '/',
  },
  /*
  ** Headers of the page
  */
  head: {
    // this htmlAttrs you need
    htmlAttrs: {
      lang: 'zh-Hant',
    },
    title: 'prject',
    meta: [
      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' },
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'keyword', name: 'keyword', content: 'yoyo' },
      { hid: 'description', name: 'description', content: 'FINPO project' },
    ]
   .....

you can find more setting on vue-meta
https://github.com/declandewet/vue-meta

All 8 comments

you can edit in nuxt.config.js

module.exports = {
  /**
   * if you want after run npm generate place dist to subdomain on webhost , you should change base 
   */
  router: {
    base: '/',
  },
  /*
  ** Headers of the page
  */
  head: {
    // this htmlAttrs you need
    htmlAttrs: {
      lang: 'zh-Hant',
    },
    title: 'prject',
    meta: [
      { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' },
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'keyword', name: 'keyword', content: 'yoyo' },
      { hid: 'description', name: 'description', content: 'FINPO project' },
    ]
   .....

you can find more setting on vue-meta
https://github.com/declandewet/vue-meta

@ausir0726 It works like charm. I really should read vue-meta's document first. Thanks !

I came here because of the same "problem". I believe the documentation should include it, maybe here: https://nuxtjs.org/guide/views/#document.

How can I declare lang attribute from $store.state ?

Would also like to know if can declare via $store.state

head(){} method in the pages can be used with $store.state I believe

@mattbag you are right

but if you are in 'spa' mode metatag placed in pages are not been see from search engine

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikekidder picture mikekidder  路  3Comments

msudgh picture msudgh  路  3Comments

bimohxh picture bimohxh  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments