vue單頁面SEO優化
阿新 • • 發佈:2019-02-07
1.1 安裝prerender-spa-plugin
vue.config.js:
const path = require('path') const PrerenderSPAPlugin = require('prerender-spa-plugin') module.exports = { plugins: [ ... new PrerenderSPAPlugin({ // Required - The path to the webpack-outputted app to prerender. staticDir: path.join(__dirname, 'dist'), // Required - Routes to render. routes: [ '/', '/about', '/some/deep/nested/route' ], }) ] }
1.2.home.vue
metaInfo() { return { title: this.pageName, meta: [ { name: "keyWords 123 333 123", content: "My Example App" } ], link: [ { rel: "asstes", href: "https://assets-cdn.github.com/" } ] }; },
11