Nuxt.js 如何做SEO优化?

Nuxt.js 如何做SEO优化?

  • 全局

在nuxt.config.js配置文件中,有个head属性可以设置全局的title,content和keywords等属性

  head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  • 局部

设置某个单独页面的title和关键字等,首先要找到这个页面的JS代码有一个head()方法,同样可以进行一些类似的设置:

head(){
    return{
        title:'豆瓣电影',
        meta:[{
            'name':'keywords',
            'content': '电影、经典电影、热映、电视剧、美剧、影评、电影院、电影票、排行、推荐'
        }]
    }
}

猜你喜欢

转载自blog.csdn.net/Calla_Lj/article/details/86596703
今日推荐