Activities

NicoPennec

NicoPennec resolved the question #c44

sitemap-module •

How does cache work?

Thanks for the encouragements @Jesus82 👍

About the cache system, it's driven by the back-end Node.js, so it's Universal mode only. It's a server-side global cache and therefore shared between all IP addresses or any HTTP requests.

AlexBa

AlexBa posted a new question

sitemap-module •

Wrong routes with /_nuxt/ prefix in sitemap

Version
v1.0.0

Reproduction link
https://alexanderbarton.de/sitemap.xml

Steps to reproduce
Just generate the sitemap with the config. :)

What is expected ?
Routes in sitemap without the /_nuxt/ prefix

What is actually happening?
Routes in sitemap with /_nuxt/ prefix

Additional comments?
This is my nuxt.config.js:

const pkg = require('./package');
const dotenv = require('dotenv');

dotenv.config();

module.exports = {
mode: 'universal',

/*
** Headers of the page
*/
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' },
]
},

/*
** Customize the progress-bar color
*/
loading: false,

/*
** Global CSS
*/
css: [
'~assets/scss/style.scss',
],

/*
** Plugins to load before mounting the App
*/
plugins: [
{src: '~plugins/bootstrap-native', ssr: false},
{src: '~plugins/tiny-slider', ssr: false}
],

/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/dotenv',
'@nuxtjs/axios',
'@nuxtjs/redirect-module',
['@nuxtjs/google-tag-manager', {
id: process.env.GTMCONTAINERID
}],
['nuxt-i18n', {
strategy: 'prefixexceptdefault',
defaultLocale: 'de',
lazy: true,
langDir: 'translations/',
locales: [
{
code: 'de',
file: 'de.json'
}
],
}],
'@nuxtjs/sitemap'
],

axios: {
// proxyHeaders: false
},

redirect: [
{ from: '^/datenschutz-erklaerung', to: '/datenschutz' }
],

/*
** Build configuration
*/
build: {
extend(config) {
config.module.rules.push({
test: /bootstrap.native/,
use: {
loader: 'bootstrap.native-loader',
options: {
only: ['collapse', 'modal']
}
}
});
}
}
};

manastalukdar

manastalukdar posted a new bug report

sitemap-module •

bug filter option with map results in error

Version

1.0.0

Reproduction link

https://github.com/manastalukdar/manastalukdar.github.io

Steps to reproduce

Run "npm run nuxt-generate" from the folder website.

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

If I remove the filter option, everything works correctly.

Problematic code:

filter({ routes }) {
      return routes.map(route => {
        if (!route.url.endsWith('.xml') && !route.url.endsWith('/')) {
          route.url = `${route.url}/`
        }
      })
    },

I have verified that the Url has the correct value. I have also tried type casting it explicitly to String, without success.

What is expected ?

sitemap.xml gets generated and the filter option works as expected.

What is actually happening?

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

j574144

j574144 posted a new feature request

sitemap-module •

idea set sitemapConfig.xslUrl

What problem does this feature solve?

Improve style of sitemap presentation

What does the proposed changes look like?

as is used in sitemap.js, pleaase add to defaults the xslUrl option.

Timkor

Timkor posted a new feature request

sitemap-module •

idea HTTPS with req.headers.host icw proxy

What problem does this feature solve?

I would like to generate https links while nuxt runs without ssl. The proxy handles this.

What does the proposed changes look like?

A new config property which can force the generated links to use https.

https://github.com/nuxt-community/sitemap-module/blob/5d029a29443862bc6f8b5c141b3b01f9312f909c/lib/module.js#L152

miguelskeeled

miguelskeeled posted a new question

sitemap-module •

Localized sitemap links duplicating

Hi,

I'm trying to implement a localized sitemap following Google's instructions (https://webmasters.googleblog.com/2012/05/multilingual-and-multinational-site.html). I managed to add the localized links to the sitemap like the following example:

<url> <loc>https://www.example.com/customers</loc> <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/kunden" /> <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/customers" /> <xhtml:link rel="alternate" hreflang="fr" href="https://www.example.com/fr/clients" /> <xhtml:link rel="alternate" hreflang="nl" href="https://www.example.com/nl/klanten" /> </url>

The problem is that after having this <url> entry, it is also generating the following <url> entries:
<url> <loc>https://www.example.com/customers</loc> </url> <url> <loc>https://www.example.com/fr/clients</loc> </url> <url> <loc>https://www.example.com/nl/klanten</loc> </url> <url> <loc>https://www.example.com/de/kunden</loc> </url>

In my website, all the pages are multilanguage so I included all my routes in the routes property of the sitemap in nuxt.config.js, and all the routes are having this duplication issue.

This is my sitemap configuration:
sitemap: { path: '/sitemap.xml', hostname: 'https://www.example.com', cacheTime: 1000 * 60 * 15, gzip: true, generate: true, routes: sitemapLinks(), }

This sitemapLinks is a synchronous function that returns an array of objects and each object has the following structure:

{ url: '/customers', links: [ { lang: 'de', url: 'de/kunden' }, { lang: 'en', url: 'customers' }, { lang: 'fr', url: 'fr/clients' }, { lang: 'nl', url: 'nl/klanten' } ]}

I have a CMS's API which I call when I run my app. This call retrieves all the pages I have in my website, and I put these routes in a static file. I then use this static file to generate the links for the sitemap routes property, to generate the pages of nuxt-i18n and also to generate the components dynamically for each page on router extendRoutes property.

I also included this module after the nuxt-i18n in nuxt.config.js.

So my problem is that basically, I'm sending all my routes with the structure showed previously to the routes property of the sitemap module, the module is generating the localized sitemap correctly, but then duplicates all the routes with a different structure in the sitemap. Am I doing anything wrong or am I missing anything?

Jesus82

Jesus82 posted a new question

sitemap-module •

How does cache work?

Hi, I have a sitemap that needs several api calls with axios in order to get all the routes, so it slows down the page loading. My question is how does exactly the cache of this module work?
If for example user A checks the page, then he cames back in 6 hours, it is clear that the sitemap will not be rebuilt. But what if user A checks the page, and then user B checks it from another IP after 6 hours? Would in that case be rebuilt for user B?

Thanks in advance and congrats for the great module!

bdrtsky

bdrtsky posted a new question

sitemap-module •

How to add lastmodISO with non-dynamic routes?

Docs covering mostly dynamic routes. I am using default settings, since I have siple website without API. So how do I add lastmodISO etc to sitemap then? It just list links by default.

bdrtsky

bdrtsky posted a new question

sitemap-module •

...

yutahaga

yutahaga posted a new bug report

sitemap-module •

bug Generation fails with --no-build option

Version

ceae48b1fc5566be1cdbe74e989ad4495968f8b5

Reproduction link

https://codesandbox.io/s/6118w7omwz

Steps to reproduce

Run yarn generate.

What is expected ?

Fix fatal error.

What is actually happening?

When I run nuxt generate --no-build, the following error occurs:

FATAL  Cannot read property 'get' of null

  at nuxt.hook (node_modules/@nuxtjs/sitemap/src/index.js:60:32)
  at utils.sequence.fn (node_modules/@nuxt/core/dist/core.js:436:53)
  at promise.then (node_modules/@nuxt/utils/dist/utils.js:1664:43)

Additional comments?

router.extendRoutes are ignored when with --no-build option, so no cache is generated.

vedees

vedees posted a new question

sitemap-module •

How to use this map data with Dynamic routes?

My code:

 return axios.all([
     axios.get('https://jsonplaceholder.typicode.com/users'),
     axios.get('https://jsonplaceholder.typicode.com/ico')
 ])
 .then(axios.spread((users, ico) => [...users.data, ...ico.data]))

How to use this?

 {
         url: '/page/2',
         changefreq: 'daily',
         priority: 1,
         lastmodISO: '2017-06-30T13:30:00.000Z'
 }


With Dynamic routes? Right now it's assigning only url.

derevandal

derevandal posted a new feature request

sitemap-module •

idea Feature request: add last modification date

What problem does this feature solve?

Adding <lastmod>2019-01-23</lastmod> in a url tag, search engines will know how this content changed and when it was added and improve the pagerank.

What does the proposed changes look like?

I suggest to use fs.stat(path, [callback]) to read mtime stat of .vue's file or .md's (I wanna use to a blog system, so, it be helpfull this support) and write in sitemap.xml

juloxrox

juloxrox posted a new bug report

sitemap-module •

bug 404 not found with firebase cloud functions

Version

0.2.0

Reproduction link

https://github.com/juloxrox/testsitemap

Steps to reproduce

Hi everyone,
When I do yarn dev or yarn build + yarn start I got sitemap.xml correctly generated when I visit /sitemap.xml.
But when it is served with firebase cloud functions, I get 404 not found. Don't know if it is firebase/nuxt/module related or am I missing something ?

I hosted an exemple here : https://github.com/juloxrox/testsitemap

Does someone has a solution for that please?
Thanks in advance

What is expected ?

200 Response for /sitemap.xml

What is actually happening?

404 not found

iggyvanlith

iggyvanlith posted a new question

sitemap-module •

Error on generating sitemap on staging & production

I'm experiencing a problem in generating the sitemap. Everything works fine on localhost and the sitemap is generated properly but when I deploy my code to Heroku it stops working and I get this error (both on staging and production):

ERROR  Cannot read property 'get' of null
at handler (node_modules/@nuxtjs/sitemap/src/index.js:117:13)
at call (node_modules/connect/index.js:239:7)
at next (node_modules/connect/index.js:183:5)
at next (node_modules/connect/index.js:161:14)
at SendStream.error (node_modules/serve-static/index.js:121:7)
at SendStream.emit (events.js:182:13)
at SendStream.EventEmitter.emit (domain.js:442:20)
at SendStream.error (node_modules/send/index.js:270:17)
at SendStream.onStatError (node_modules/send/index.js:421:12)
at onstat (node_modules/send/index.js:727:26)
at FSReqWrap.oncomplete (fs.js:152:21)

So this would be in this file: https://github.com/nuxt-community/sitemap-module/blob/dev/src/index.js. And I guess it has something to do with the cache not being created?

I've removed all the settings and custom routes from the module so it's just included with this piece now:

modules: [
   ...more modules...
   ['@nuxtjs/sitemap'],
   ...more modules...
]

I've tried reproducing this error with a blank nuxt installation with just this module deploying to heroku but with no success (as in, a sitemap is properly generated). The problem is probably somewhere in my codebase but I'm not sure where to start looking.

Any idea where I should start to solve this error?

agjini

agjini posted a new question

sitemap-module •

Access to nuxt context inside routes generation function

What i try achieve is to generate dynamic routes in the sitemap using data contained in the vuex store.

But I'm not able to access to any variable in the context as $store.

Is there any chance to get this working ? Or a plan to add access to the nuxt context as a parameter of the 'routes' option in nuxt-sitemap ?

Thanks in advance

alfonsobries

alfonsobries posted a new feature request

sitemap-module •

idea Add localization to the sitemap.xml

What problem does this feature solve?

Currently, it's not possible to add localization to a sitemap.xml in a multilingual site accordingly to the Google recommendations

https://support.google.com/webmasters/answer/189077

What does the proposed changes look like?

The possibility to generate sitemaps like this:

```
<url>
    <loc>http://www.example.com/english/page.html</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>
alfonsobries

alfonsobries posted a new question

sitemap-module •

Feature request: Add localization to the sitemap

Currently it's not possible to add localization to a sitemap.xml accordingly to the google recommendations

https://support.google.com/webmasters/answer/189077

<url>
    <loc>http://www.example.com/english/page.html</loc>
    <xhtml:link 
               rel="alternate"
               hreflang="de"
               href="http://www.example.com/deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="de-ch"
               href="http://www.example.com/schweiz-deutsch/page.html"/>
    <xhtml:link 
               rel="alternate"
               hreflang="en"
               href="http://www.example.com/english/page.html"/>
  </url>
yuanwei92

yuanwei92 posted a new question

sitemap-module •

Sitemap could not be found after deployment to Firebase functions

Hi, the sitemap module works perfectly in local production build. However after I deployed it to Firebase functions, the page could not be found. I wonder what could be the issue? The dist files were hosted on Firebase hosting.

nuxt.config.js

sitemap: {
  hostname: 'https://shopsavee.com',
  routes: []
},
build: {
  publicPath: '/',
  vendor: ['babel-polyfill'],
  extractCSS: true,
  babel: {
    presets: [['@babel/preset-env']],
    plugins: [
      '@babel/plugin-transform-runtime',
      '@babel/plugin-syntax-dynamic-import'
    ]
  },
}
egidioFrat

egidioFrat posted a new feature request

sitemap-module •

idea An option for trailing slash would improve SEO

What problem does this feature solve?

Missing trailing slash on URL of a directory force github pages to redirect HTTPS to HTTP.
https://github.com/isaacs/github/issues/289

What does the proposed changes look like?

It could be an option to add trailing slash to static URL in sitemap.xml

SnirShechter

SnirShechter posted a new feature request

sitemap-module •

idea Support Localized sitemaps (using nuxt-i18n)

What problem does this feature solve?

There is no way of automatically generating a sitemap when the site is localized (using nuxt-i18n, for example).

Two difficulties when using the sitemap module with the nuxt-i18n localization:

  1. Prefixes ('/en').
  2. Url localization (/en/shop becomes /fr/boutique or so).

What does the proposed changes look like?

I suggest (if in any way possible) to generate the static pages using the router routes after they were already generated by the nuxt-i18n module.