nuxt-seo-module
Nuxt Module that generate sitemap, robot.txt and many things like that
Getting started
Install
Install it via NPM:
npm i nuxt-seo-module
or via yarn:
yarn add nuxt-seo-module
Add it to nuxt
Add it to your nuxt.config.js
file.
/** ... **/ modules: /* ... */ 'nuxt-seo-module' /** ... **/
It will create a robots.txt
file and a sitemap.xml with all of your pages
Options
nuxt-seo-module is composed of 2 modules, the robots and the sitemap one. You can configure them individually :
/** ... **/ modules: /* ... */ 'nuxt-seo-module' robots: // ROBOTS.TXT options sitemap: // sitemaps options is an array of object /** ... **/
robots.txt options
modules: /* ... */ 'nuxt-seo-module' robots: UserAgent: '' CrawlDelay: '' Disallow: '' Allow: '' Sitemap: ''
Each parameters can be a string or an array.
If you add a sitemap entry in your robots.txt, generated sitemap will not be added to the robots.txt file.
sitemap options
A complete example of sitemap options:
modules: /* ... */ 'nuxt-seo-module' sitmap: path: 'sitemap.xml' hostname: null generate: true exclude: routes: url: '/page/2' changefreq: 'daily' priority: 1 lastmodISO: '2017-06-30T13:30:00.000Z' url: '/page/1' changefreq: 'daily' priority: 03 lastmodISO: '2017-06-30T13:30:00.000Z' links: lang: 'en' url: 'http://test.com/page-1/' lang: 'fr' url: 'http://test.com/page-1/fr/' androidLink: 'android-app://com.company.test/page-1/' cacheTime: 1000 * 60 * 15 path: 'sitemap-news.xml' hostname: 'my-url.com' generate: false routes:
nuxt env variable
You can also use env variable in nuxt.config.js
:
/** ... **/modules: /* ... */ 'nuxt-seo-module'env: robots: {} sitemap: generate: true /** ... **/