Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
gatsby-plugin-sitemap Putting trailing slash to homepage only

Hello Guys I am using plugin above to create a sitemap for Gatsby website, and removing forward slashes from all urls, but when I check the sitemap it is putting trailing slash to the homepage only here is the code.

serialize: ({ path }) => {
      let domain = process.env.url || 'https://example.com';
      domain =
        domain.charAt(domain.length - 1) === '/' ? domain.slice(1) : domain;
      let pathStr =
        path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
      let url = domain + pathStr;
      console.log(url);
      return {
        url,
        changefreq: 'daily',
        priority: 0.7
      };
    }

url is getting displayed in console, and there is no any trailing slashes, but in sitemap there is.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

With the v4.7 of Gatsby, there's a built-in option to customize the behavior of the trailing slashes across your application. It's currently in beta but should fix your issue.

trailingSlash Option Currently in Public Beta

Through the RFC Integrated handling of trailing slashes in Gatsby we’ve worked on making the trailing slashes feature a first-class citizen in Gatsby. We’re happy to announce that gatsby-config now supports a trailingSlash configuration with these three main options:

  • always: Always add trailing slashes to each URL, e.g. /x to /x/.

  • never: Remove all trailing slashes on each URL, e.g. /x/ to /x.

  • ignore: Don’t automatically modify the URL.

You can simply customize it using:

module.exports = {
  trailingSlash: "never"
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda