Giter Site home page Giter Site logo

gatsby-plugin-advanced-sitemap's Introduction

gatsby-plugin-advanced-sitemap

The default Gatsby sitemap plugin generates a simple blob of raw XML for all your pages. This advanced sitemap plugin adds more power and configuration, generating a single or multiple sitemaps with full XSL templates to make them neatly organised and human + machine readable, as well linking image resources to encourage media indexing.

Demo: https://gatsby.ghost.org/sitemap.xml

 

example

NOTE: This plugin only generates output in production mode! To test, run: gatsby build && gatsby serve

 

Install

npm install --save gatsby-plugin-advanced-sitemap

How to Use

By default this plugin will generate a single sitemap of all pages on your site, without any configuration needed.

// gatsby-config.js

siteMetadata: {
    siteUrl: `https://www.example.com`,
},
plugins: [
    `gatsby-plugin-advanced-sitemap`
]

 

Options

If you want to generate advanced, individually organised sitemaps based on your data, you can do so by passing in a query and config. The example below uses Ghost, but this should work with any data source - including Pages, Markdown, Contentful, etc.

Example:

// gatsby-config.js

plugins: [
    {
        resolve: `gatsby-plugin-advanced-sitemap`,
        options: {
             // 1 query for each data type
            query: `
            {
                allGhostPost {
                    edges {
                        node {
                            id
                            slug
                            updated_at
                            feature_image
                        }
                    }
                }
                allGhostPage {
                    edges {
                        node {
                            id
                            slug
                            updated_at
                            feature_image
                        }
                    }
                }
                allGhostTag {
                    edges {
                        node {
                            id
                            slug
                            feature_image
                        }
                    }
                }
                allGhostAuthor {
                    edges {
                        node {
                            id
                            slug
                            profile_image
                        }
                    }
                }
            }`,
            // The filepath and name to Index Sitemap. Defaults to '/sitemap.xml'.
            output: "/custom-sitemap.xml",
            mapping: {
                // Each data type can be mapped to a predefined sitemap
                // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name
                // The default sitemap - if none is passed - will be pages
                allGhostPost: {
                    sitemap: `posts`,
                    // Add a query level prefix to slugs, Don't get confused with global path prefix from Gatsby
                    // This will add a prefix to this particular sitemap only
                    prefix: 'your-prefix/',
                    // Custom Serializer 
                    serializer: (edges) => {
                        return edges.map(({ node }) => {
                            (...) // Custom logic to change final sitemap.
                        })
                    }
                },
                allGhostTag: {
                    sitemap: `tags`,
                },
                allGhostAuthor: {
                    sitemap: `authors`,
                },
                allGhostPage: {
                    sitemap: `pages`,
                },
            },
            exclude: [
                `/dev-404-page`,
                `/404`,
                `/404.html`,
                `/offline-plugin-app-shell-fallback`,
                `/my-excluded-page`,
                /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example
            ],
            createLinkInHead: true, // optional: create a link in the `<head>` of your site
            addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
            additionalSitemaps: [ // optional: add additional sitemaps, which are e. g. generated somewhere else, but need to be indexed for this domain
                {
                    name: `my-other-posts`,
                    url: `/blog/sitemap-posts.xml`,
                },
                {
                    url: `https://example.com/sitemap.xml`,
                },
            ],
        }
    }
]

Example output of ☝️ this exact config 👉 https://gatsby.ghost.org/sitemap.xml

Develop Plugin

  • Pull the repo
  1. Install dependencies
yarn install

Build Plugin

yarn build

Run Tests

yarn test

 

Copyright & License

Copyright (c) 2013-2023 Ghost Foundation - Released under the MIT license.

gatsby-plugin-advanced-sitemap's People

Contributors

aileen avatar ayzagen avatar cbw2007 avatar daniellockyer avatar daviddarnes avatar generalpiston avatar good3n avatar joeegrigg avatar johnonolan avatar mateustav avatar muravitskiy avatar renovate-bot avatar renovate[bot] avatar rohit-gohri avatar sanderfish avatar swiip avatar yogeshkotadiya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatsby-plugin-advanced-sitemap's Issues

Allow custom serializers

Issue Summary

Allow to send in custom serializer for graph data, so that your graph data will work with plugin.

This is the area that is the issue:

const serialize = ({ ...sources } = {},{ site, allSitePage }, mapping) => {

ERROR #11321 PLUGIN

"gatsby-plugin-advanced-sitemap" threw an error while running the onPostBuild lifecycle:

node.slug.replace is not a function

TypeError: node.slug.replace is not a function

  • gatsby-node.js:200
    [web]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:200:132

To Reproduce

  1. Setup any API that does not use slug directly (in my example it is using sanity.io).

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Here is a sample of the graph data:

{
  "data": {
    "allSanityAuthor": {
      "edges": [
        {
          "node": {
            "id": "cdc8ffaa-d817-5f39-aa78-18c01339243b",
            "slug": {
              "current": "alex-patterson"
            },
            "_updatedAt": "2019-09-30T14:05:08Z",
            "image": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/5eadf06f02778c3b1dec1ed67c504241fd4d1f9a-432x432.png"
              }
            }
          }
        }
      ]
    },
    "allSanityBlogPost": {
      "edges": [
        {
          "node": {
            "id": "e7757105-5d16-5ef1-87fc-bbb2dd5a7e38",
            "title": "Cloud Function GitHub Update",
            "publishedAt": "2018-12-26T01:25:37.000-05:00",
            "slug": {
              "current": "cloud-function-github-update"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/eeef21dd96e8a299ccb2dfbcad5156781d0d7d0d-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "cf0dbba3-9b32-5eda-9f4c-bf751148eb7d",
            "title": "Slack Workspace Theme Customization",
            "publishedAt": "2019-08-14T21:33:41.000-04:00",
            "slug": {
              "current": "slack-workspace-theme-customization"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/66c060eacf95f2940dae42d7edf4d131cd52a2b0-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "ae721962-ecf1-5566-acf1-17096974e285",
            "title": "Better Performance through analysis.",
            "publishedAt": "2019-08-17T11:33:41.000-04:00",
            "slug": {
              "current": "better-performance-through-analysis"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/edeed56fbd77dd393cca2604368c6e06c5b58491-3641x2048.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "7318b24a-074d-505c-a2c1-6be0123db083",
            "title": "Adding Angular Reactive Form Web Component to Static Site",
            "publishedAt": "2019-09-11T03:33:41.000-04:00",
            "slug": {
              "current": "adding-angular-reactive-form-web-component-to-static-site"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/a7c61440d3c5bd915a0deb54eeeb364dd72d59c9-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "b20e628e-98da-5467-b1ea-b62bf18ada36",
            "title": "Firebase Hosting Version Settings",
            "publishedAt": "2019-08-22T03:33:41.000-04:00",
            "slug": {
              "current": "firebase-hosting-version-settings"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/08db7925429fe741fd36e6d1e4b8b2d34972c9fc-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "dbc00c00-128e-585c-809e-e0dbd2038742",
            "title": "Ionic Icons",
            "publishedAt": "2019-01-20T01:25:38.000-05:00",
            "slug": {
              "current": "ionic-icons"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/445684b29a1c2cc31ea87faa014e73ce8c6183f2-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "b909f183-0bef-5c4f-8e54-712252b1f5c4",
            "title": "Adding Web Component for Ionic Modals",
            "publishedAt": "2019-09-10T03:33:41.000-04:00",
            "slug": {
              "current": "adding-web-component-for-ionic-modals"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/a7c61440d3c5bd915a0deb54eeeb364dd72d59c9-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "a61d0a97-6c38-5fa5-8c54-63273de53331",
            "title": "Front End Web Development Podcasts",
            "publishedAt": "2019-08-18T01:33:41.000-04:00",
            "slug": {
              "current": "front-end-web-development-podcasts"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/395b7d00fc00bfe619dc7add36a9d282376e17c0-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "b71c7dd3-5f58-591d-81b4-93c3b175d52b",
            "title": "Adding Angular Components to your static site",
            "publishedAt": "2019-09-09T03:33:41.000-04:00",
            "slug": {
              "current": "adding-angular-components-to-your-static-site"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/a7c61440d3c5bd915a0deb54eeeb364dd72d59c9-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "d9a3fe81-bd8d-5e23-958c-d68b59065ae8",
            "title": "VSCode Extension Peacock",
            "publishedAt": "2019-05-10T21:33:41.000-04:00",
            "slug": {
              "current": "vscode-extension-peacock"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/e60649dbd7fbbb3c2e2116259a6179610a9d305f-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "31f85f1b-8088-5b6d-9b10-d51c15ff5146",
            "title": "AJonP - Rebranded",
            "publishedAt": "2018-11-04T21:56:55.000-05:00",
            "slug": {
              "current": "ajonp-rebranded"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/69d43ff4c5f4fbfbc8dec13b78cacca4c0c94d55-1429x467.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "e5ee1e8d-31af-5a28-a99d-1b7bd6ebb187",
            "title": "JAMStack GR started",
            "publishedAt": null,
            "slug": {
              "current": "jamstack-gr-started"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/504480f2239993b84024627cc62f5c22567f31d9-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "d6fb921b-e118-5f50-adae-197085713e81",
            "title": "Cloudinary in Jamstacks using Webp",
            "publishedAt": "2019-07-31T03:33:41.000-04:00",
            "slug": {
              "current": "cloudinary-in-jamstacks-using-webp"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/e6c0a2a51ca46b3ac3fcb5ba94d1a10c8161ce94-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "a873de03-3feb-5432-8e0f-997203ebc634",
            "title": "Building a Fun App With Ionic Studio and Cloudinary",
            "publishedAt": "2019-08-12T03:33:41.000-04:00",
            "slug": {
              "current": "building-a-fun-app-with-ionic-studio-and-cloudinary"
            },
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/57375227ebd1ec6dd48ef678e76f36bc7ea2cfd2-1920x1080.png"
              }
            }
          }
        }
      ]
    },
    "allSanityCourse": {
      "edges": [
        {
          "node": {
            "id": "5f2d0397-4e1e-5f09-952c-ef71a15def6a",
            "slug": {
              "current": "javascript-for-a-10-year-old"
            },
            "_updatedAt": "2019-09-30T13:41:37Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/11842fc4d94b50f6b69c6697b195bd3248ccfa27-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "d6eb446c-e986-555b-bd57-729668735e67",
            "slug": {
              "current": "html-for-a-10-year-old"
            },
            "_updatedAt": "2019-09-30T13:39:44Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/6b4aa53c73d409a03b8c0b6791e1cc51440309fe-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "8de5eb5b-4fbb-5600-915f-5c236b8bb98d",
            "slug": {
              "current": "css-for-a-10-year-old"
            },
            "_updatedAt": "2019-09-30T13:41:31Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/7f2d8c36efe6a72611f22bf5b0f5df069e056c36-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "a6d122dc-58e7-5596-8d5d-329ec4c8b9ec",
            "slug": {
              "current": "nextjs9"
            },
            "_updatedAt": "2019-09-30T13:42:14Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/89b755e1e96e24eb7c8e60fb66bcf484923830f5-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "36b1ed30-8705-5e05-b3b7-744c92622ed6",
            "slug": {
              "current": "svelte3"
            },
            "_updatedAt": "2019-09-30T13:46:26Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/88885ba1659b5d80361e05caa8800cb8240dfdfc-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "b0546b55-d560-54b6-bd16-ca24a564c55a",
            "slug": {
              "current": "angularmaterial"
            },
            "_updatedAt": "2019-09-30T13:36:58Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/75346ad2ae21a468aa2c2933847030d639cc62c2-1920x1080.png"
              }
            }
          }
        }
      ]
    },
    "allSanityLesson": {
      "edges": [
        {
          "node": {
            "id": "db70542f-f163-529d-9ad5-3fc22ee2e833",
            "slug": {
              "current": "slap-someone-with-slack-commands"
            },
            "_updatedAt": "2019-09-30T13:47:54Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/e7c793bc5d7899e620c1ffd373719f80c56648ab-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "da1b225c-aae8-591a-9a73-0ce5fa068a3a",
            "slug": {
              "current": "rxfire-in-svelte-3-using-firebase-firestore-and-authentication"
            },
            "_updatedAt": "2019-09-30T13:58:36Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/f5208d3c8684baddcf4ea2cf18853c0389989bd9-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "2b95110d-d9c8-5c81-ad5a-2b02ea080f5c",
            "slug": {
              "current": "npm-tips-and-tricks"
            },
            "_updatedAt": "2019-09-30T14:02:40Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/04cefdc0178a79f90c98259fa016bf0366dee925-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "2c99800e-374a-536d-943c-8db193ae686c",
            "slug": {
              "current": "design-systems-with-web-components"
            },
            "_updatedAt": "2019-09-30T13:58:11Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/53ef63ca6835fa560f94ab0aa5732576954124be-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "c772dfad-348a-50f7-8ded-8d850dd47b4b",
            "slug": {
              "current": "ajonp-hugo-ionic-template"
            },
            "_updatedAt": "2019-09-30T14:02:09Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/2579b41582b734e4cd1e176409e514ef62f7b24f-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "ce47beb0-36b2-5998-a50f-1a137601932e",
            "slug": {
              "current": "google-cloud-repositories-ci-cd"
            },
            "_updatedAt": "2019-09-30T14:03:22Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/758c501ff499c843b3ff43739c33169f94f0ed4a-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "6d32cfe7-c2bc-5543-9924-6226f3064b41",
            "slug": {
              "current": "use-firestore-to-build-hugo-content"
            },
            "_updatedAt": "2019-09-30T13:59:45Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/47168182bfed85ad05b2a27ec12ac30e9532d86c-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "6ede9650-1ebd-5281-aeac-2ed1adf44489",
            "slug": {
              "current": "firebase-multisite-hosting"
            },
            "_updatedAt": "2019-09-30T14:01:30Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/860cb0888f9282b5ed524bb15fc94fa7ef173e35-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "7cd50c02-061f-51cc-b0e8-df3efca3f5cd",
            "slug": {
              "current": "abap-hello-world"
            },
            "_updatedAt": "2019-09-30T14:04:15Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/d328f8a9f139f35463c46a30e78d71c89964c403-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "26665fae-cebf-554e-937d-9c32103ac80b",
            "slug": {
              "current": "rxfire-in-reactjs-using-firebase-firestore-and-authentication"
            },
            "_updatedAt": "2019-09-30T13:58:51Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/40f14bbf8155990e227aad46e07b92b7d1a1e473-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "75103431-f381-57dc-8fbc-1ef3d2b4e48b",
            "slug": {
              "current": "hugo-ionic-template"
            },
            "_updatedAt": "2019-09-30T14:01:48Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/3a922db4147436103ef858d84ed0c5a7c401495d-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "d746b372-3924-5900-a63b-1c7d4c8549b2",
            "slug": {
              "current": "abap-types-and-subroutines"
            },
            "_updatedAt": "2019-09-30T14:03:51Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/1e05b2bbdd0197071ffd07f534d643bf08113204-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "c7b6cb2c-acb1-59cc-a3e5-a0dadd828746",
            "slug": {
              "current": "angular-pwa-to-google-play-store-using-trusted-web-activity"
            },
            "_updatedAt": "2019-09-30T13:59:11Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/3477c87dff2cdc6defc4066cb5d99b3418d5eab6-1920x1080.png"
              }
            }
          }
        }
      ]
    },
    "allSanityNote": {
      "edges": []
    },
    "allSanityModule": {
      "edges": [
        {
          "node": {
            "id": "021955bb-59c6-5e83-ae3f-e6966767eaae",
            "slug": {
              "current": "firebase-project-hosting"
            },
            "_updatedAt": "2019-09-30T13:56:41Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/2cb3d51ebf7963430a989330767e3c4df4531dc1-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "85afc721-6220-50db-9591-85834cce45f3",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-firestore-modeling"
            },
            "_updatedAt": "2019-09-30T13:50:23Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/8ceea98ff881233e453dd3f43ba34494b0b49981-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "66db828a-8764-5c38-a95f-f8434161e04c",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-ssr-part-1"
            },
            "_updatedAt": "2019-09-30T13:49:40Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/40a0f3710e767823c0bbeb6add2ae248ec9a3ea7-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "c475f636-e339-51b0-9b59-feac440191f1",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-navigation"
            },
            "_updatedAt": "2019-09-30T13:50:40Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/6ae61ccf928c784178a3e7504abe62f8a95c3443-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "5f27f62b-0054-5765-9aa9-a04a638f7c53",
            "slug": {
              "current": "angular-material-router-awareness"
            },
            "_updatedAt": "2019-09-30T13:52:59Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/09545e8792e7311286180abadd5ce893513bd6ea-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "fef61dfd-85f6-5b44-a23a-bb793e254cf7",
            "slug": {
              "current": "angular-material-forms-from-firestore"
            },
            "_updatedAt": "2019-09-30T13:53:50Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/64dd7a57833bfd87840ab3efb644ea53579ea619-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "95e7dc30-d3aa-5e70-b362-279499662e3f",
            "slug": {
              "current": "angular-material-dynamic-navigation-using-firestore"
            },
            "_updatedAt": "2019-09-30T13:54:21Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/448a2fe373938ea71135f1c5c4b0b1325fb903df-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "81baed0d-ace9-5517-94ae-211625a4349d",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-intro"
            },
            "_updatedAt": "2019-09-30T13:51:56Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/1ebc3daea2703595366742baa0330dc36b3a72c5-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "cee70cda-5c9e-5f85-90d8-699802eb213e",
            "slug": {
              "current": "firebase-authentication-and-authorization"
            },
            "_updatedAt": "2019-09-30T13:52:37Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/0d3805af61a7c420469580a8c13716d7afeaaa27-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "d8e3a82d-0c1a-581a-b6f8-6bfebb5fbd19",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-materialui"
            },
            "_updatedAt": "2019-09-30T13:51:09Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/2e132d3ffb6f9b5965e85c0226aae8f739724c35-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "12049f04-e2c6-5fd0-802c-d87475508d33",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-project-hosting"
            },
            "_updatedAt": "2019-09-30T13:50:07Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/91d18c280666aee445553e6ded0177cf831bd41f-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "144adeb8-cd70-568f-88e3-ce298d9586e1",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-ssr-part-2"
            },
            "_updatedAt": "2019-09-30T13:49:25Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/a4ee60d89bc3dc7432cefe07dfaac939b8455e62-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "327516ec-f506-5fc6-8551-7f91f38c5404",
            "slug": {
              "current": "nextjs-using-materialui-and-firebase-setup"
            },
            "_updatedAt": "2019-09-30T13:51:19Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/d82892bd005455cc08a1b078b20b32dfc0d8e988-1920x1080.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "c3b9cc7b-602b-518f-8b58-31fe25010c61",
            "slug": {
              "current": "angular-material-router-outlet"
            },
            "_updatedAt": "2019-09-30T13:55:05Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/5887cad9cdc8718e4a64e696165d73e95ad2d0c8-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "cae02c29-18a8-5d2a-a594-c2446339709e",
            "slug": {
              "current": "angular-material-theming"
            },
            "_updatedAt": "2019-09-30T13:54:46Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/e9452fd9e48c34078bb59d30f9e252f1ec7136d9-1280x720.png"
              }
            }
          }
        },
        {
          "node": {
            "id": "fe4621a2-6e06-5895-8a41-a088e7928ea4",
            "slug": {
              "current": "angular-material-reactive-forms-update-firestore"
            },
            "_updatedAt": "2019-09-30T13:53:28Z",
            "mainImage": {
              "asset": {
                "url": "https://cdn.sanity.io/images/hfh83o0w/production/2ef0e4b0834094083b65b576dcd1af64e27ae076-1920x1080.png"
              }
            }
          }
        }
      ]
    }
  }
}

Technical details:

  • Gatsby Version: 2.15.20
  • Node Version: 10.16.3
  • OS: MacOS
  • gatsby-config.js:
// Load variables from `.env` as soon as possible
require("dotenv").config({
  path: `.env.${process.env.NODE_ENV || "development"}`
});

const PortableText = require('@sanity/block-content-to-html')
const h = PortableText.h

const clientConfig = require("./client-config");
const imageUrlFor = source => imageUrlBuilder(clientConfig.sanity).image(source)

const isProd = process.env.NODE_ENV === "production";

module.exports = {
  siteMetadata: {
    title: `AJ on Purr-fect Solutions`,
    //siteUrl: `https://ajonp.com`,
    siteUrl: `https://beta.ajonp.com`,
    description: `A Community of developers, creating resources for all to use!`,
  },
  plugins: [
    `gatsby-plugin-typescript`,
    "gatsby-plugin-postcss",
    "gatsby-plugin-react-helmet",
    {
      resolve: "gatsby-source-sanity",
      options: {
        ...clientConfig.sanity,
        token: process.env.SANITY_READ_TOKEN,
        watchMode: !isProd,
        overlayDrafts: !isProd
      }
    },
    {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
          query: `
          {
            allSanityAuthor {
              edges {
                node {
                  id
                  slug {
                    current
                  }
                  _updatedAt
                  image {
                    asset {
                      url
                    }
                  }
                }
              }
            }
            allSanityBlogPost(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
              edges {
                node {
                  id
                  title
                  publishedAt
                  slug {
                    current
                  }
                  _rawExcerpt(resolveReferences: {maxDepth: 50})
                  _rawBody(resolveReferences: {maxDepth: 10})
                }
              }
            }
            allSanityCourse {
              edges {
                node {
                  id
                  slug {
                    current
                  }
                  _updatedAt
                  mainImage {
                    asset {
                      url
                    }
                  }
                }
              }
            }
            allSanityLesson(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
              edges {
                node {
                  id
                  slug {
                    current
                  }
                  _updatedAt
                  mainImage {
                    asset {
                      url
                    }
                  }
                }
              }
            }
            allSanityNote(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
              edges {
                node {
                  id
                  slug {
                    current
                  }
                  _updatedAt
                  mainImage {
                    asset {
                      url
                    }
                  }
                }
              }
            }
            allSanityModule(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
              edges {
                node {
                  id
                  slug {
                    current
                  }
                  _updatedAt
                  mainImage {
                    asset {
                      url
                    }
                  }
                }
              }
            }
          }
          `,
          // mapping: {
          //     // Each data type can be mapped to a predefined sitemap
          //     // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name
          //     // The default sitemap - if none is passed - will be pages
          //     allSanityAuthor: {
          //         sitemap: `authors`,
          //     },
          //     allSanityBlogPost: {
          //         sitemap: `blog`,
          //     },
          //     allSanityCourse: {
          //         sitemap: `courses`,
          //     },
          //     allSanityLesson: {
          //         sitemap: `lessons`,
          //     },
          //     allSanityNote: {
          //       sitemap: `notes`,
          //     },
          //     allSanityModule: {
          //         sitemap: `coursemodules`,
          //     },
          // },
          exclude: [
              `/dev-404-page`,
              `/404`,
              `/404.html`,
              `/offline-plugin-app-shell-fallback`,
              `/my-excluded-page`,
              /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example
          ],
          createLinkInHead: true, // optional: create a link in the `<head>` of your site
          addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
      }
  },
    {
      resolve: `gatsby-plugin-feed`,
      options: {
        query: `
          {
            site {
              siteMetadata {
                title
                description
                siteUrl
                site_url: siteUrl
              }
            }
          }
        `,
        feeds: [
          {
            serialize: ({ query: { site, allSanityBlogPost, allSanityLesson, allSanityModule  } }) => {
              const blog = allSanityBlogPost.edges.map(edge => {
                const { slug, title, publishedAt, _rawBody, _rawExcerpt } = edge.node;
                let path = `/blog/${slug.current}`;
                return Object.assign({}, {
                  title: title,
                  description: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawExcerpt,
                      })
                    }
                  ],
                  date: publishedAt,
                  url: site.siteMetadata.siteUrl + path,
                  guid: site.siteMetadata.siteUrl + path,
                  custom_elements: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawBody,
                        serializers: {
                          types: {
                            code: ({ node }) =>
                              h(
                                'pre',
                                h('code', { lang: node.language }, node.code)
                              ),
                            mainImage: ({ node }) =>
                              h('img', {
                                src: imageUrlFor(node.asset).url()
                              }),
                            img: ({ node }) => {
                              const { asset } = node;
                              h('img', {
                                src:asset.img
                              })
                            }
                          }
                        }
                      })
                    }
                  ]
                })
              });

              const lessons = allSanityLesson.edges.map(edge => {
                const { slug, title, publishedAt, _rawBody, _rawExcerpt } = edge.node;
                let path = `/lessons/${slug.current}`;
                return Object.assign({}, {
                  title: title,
                  description: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawExcerpt,
                      })
                    }
                  ],
                  date: publishedAt,
                  url: site.siteMetadata.siteUrl + path,
                  guid: site.siteMetadata.siteUrl + path,
                  custom_elements: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawBody,
                        serializers: {
                          types: {
                            code: ({ node }) =>
                              h(
                                'pre',
                                h('code', { lang: node.language }, node.code)
                              ),
                            mainImage: ({ node }) =>
                              h('img', {
                                src: imageUrlFor(node.asset).url()
                              }),
                            img: ({ node }) => {
                              const { asset } = node;
                              h('img', {
                                src:asset.img
                              })
                            }
                          }
                        }
                      })
                    }
                  ]
                })
              });

              const courseModules = allSanityModule.edges.map(edge => {
                const { slug, course, title, publishedAt, _rawBody, _rawExcerpt } = edge.node;
                let path = `/courses/${course.slug.current}/${slug.current}`;
                return Object.assign({}, {
                  title: title,
                  description: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawExcerpt,
                      })
                    }
                  ],
                  date: publishedAt,
                  url: site.siteMetadata.siteUrl + path,
                  guid: site.siteMetadata.siteUrl + path,
                  custom_elements: [
                    {
                      'content:encoded': PortableText({
                        blocks: _rawBody,
                        serializers: {
                          types: {
                            code: ({ node }) =>
                              h(
                                'pre',
                                h('code', { lang: node.language }, node.code)
                              ),
                            mainImage: ({ node }) =>
                              h('img', {
                                src: imageUrlFor(node.asset).url()
                              }),
                            img: ({ node }) => {
                              const { asset } = node;
                              h('img', {
                                src:asset.img
                              })
                            }
                          }
                        }
                      })
                    }
                  ]
                })
              });
              return [...blog, ...lessons, ...courseModules];
            },
            query: `
            {
              allSanityBlogPost(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
                edges {
                  node {
                    id
                    title
                    publishedAt
                    slug {
                      current
                    }
                    _rawExcerpt(resolveReferences: {maxDepth: 50})
                    _rawBody(resolveReferences: {maxDepth: 10})
                  }
                }
              }
              allSanityLesson(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
                edges {
                  node {
                    id
                    title
                    publishedAt
                    slug {
                      current
                    }
                    _rawExcerpt(resolveReferences: {maxDepth: 50})
                    _rawBody(resolveReferences: {maxDepth: 10})
                  }
                }
              }
              allSanityModule(filter: {slug: {current: {ne: "null"}}, publishedAt: {ne: "null"}}) {
                edges {
                  node {
                    id
                    title
                    publishedAt
                    slug {
                      current
                    }
                    course {
                      slug {
                        current
                      }
                    }
                    _rawExcerpt(resolveReferences: {maxDepth: 50})
                    _rawBody(resolveReferences: {maxDepth: 10})
                  }
                }
              }
            }
            `,
            output: "/index.xml",
            title: "AJonP's RSS Feed",
          },
        ],
      },
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `AJ on Purr-fect Solutions`,
        short_name: `AJonP`,
        start_url: `/`,
        background_color: `#5E1286`,
        theme_color: `#5E1286`,
        display: `standalone`,
        icon: `src/images/aj_logo_512x512.png`
      }
    },
    `gatsby-plugin-offline`,
  ]
};

getting 1 page returned

Issue Summary

passing a graphql query to retrieve all site pages and all news articles. This query works fine in gatsby develop and i get back lots of records. However when i use the plugin it's returning the first record?

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version: 2.13.65
  • Node Version: 10.15.3
  • OS:Mac OS
  • gatsby-config.js:
` {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
           // 1 query for each data type
          query: `
          {
            allPrismicNewsArticlePage(sort: {order: DESC, fields: data___article_date}, filter: {lang: {eq: "en-gb"}}) {
              edges {
                node {
                  slug: uid
                }
              }
            }
            allSitePage {
              edges {
                node {
                  slug: path
                }
              }
            }
           
          }
          `,
          mapping: {
              // Each data type can be mapped to a predefined sitemap
              // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name
              // The default sitemap - if none is passed - will be pages
              allSitePage: {
                sitemap: `pages`,
              },
              allPrismicNewsArticlePage: {
                sitemap: `news`,
            },
              
          },
          exclude: [
              `/dev-404-page`,
              `/404`,
              `/404.html`,
          ],
          createLinkInHead: true, // optional: create a link in the `<head>` of your site
          addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
      }`

I have aliased to slug as it appears the code is looking for a slug

Contentful last update is wrong

I use this for contentful posts

allContentfulPost {
            edges {
              node {
                id
                slug
                updatedAt
              }
            }
          }

but Last Modified column always shows the wrong date (the build date) and not when the post was updated, is there a fix for this?

Gatsby v5 support

Welcome to the Gatsby Plugin Advanced Sitemap GitHub repo! 👋🎉

We use GitHub only for bug reports 🐛

Anything else should be posted to https://forum.ghost.org 👫

For questions related to the usage of Gatsby or GraphQL, please check out their docs at https://www.gatsbyjs.org/ and https://graphql.org/

🚨For support, help & questions use https://forum.ghost.org/c/help
💡For feature requests & ideas you can post and vote on https://forum.ghost.org/c/Ideas

If your issue is with Gatsby.js itself, please report it at the Gatsby repo ➡️ https://github.com/gatsbyjs/gatsby/issues/new.

Issue Summary

npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/gatsby
npm ERR! peer gatsby@"^5.0.0-next" from [email protected]
npm ERR! node_modules/babel-plugin-remove-graphql-queries
npm ERR! babel-plugin-remove-graphql-queries@"^5.0.0" from [email protected]
npm ERR! babel-plugin-remove-graphql-queries@"^5.0.0" from [email protected]
npm ERR! node_modules/gatsby-plugin-image
npm ERR! peer gatsby-plugin-image@"^3.0.0-next" from [email protected]
npm ERR! node_modules/gatsby-source-wordpress
npm ERR! gatsby-source-wordpress@"^7.0.0" from the root project
npm ERR! 1 more (the root project)
npm ERR! 1 more (gatsby-plugin-typescript)
npm ERR! peer gatsby@"^5.0.0-next" from [email protected]
npm ERR! node_modules/gatsby-plugin-catch-links
npm ERR! gatsby-plugin-catch-links@"^5.0.0" from [email protected]
npm ERR! node_modules/gatsby-source-wordpress
npm ERR! gatsby-source-wordpress@"^7.0.0" from the root project
npm ERR! 24 more (gatsby-plugin-google-tagmanager, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer gatsby@"^3.0.0 || ^4.0.0" from [email protected]
npm ERR! node_modules/gatsby-plugin-advanced-sitemap
npm ERR! gatsby-plugin-advanced-sitemap@"^2.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/gatsby
npm ERR! peer gatsby@"^3.0.0 || ^4.0.0" from [email protected]
npm ERR! node_modules/gatsby-plugin-advanced-sitemap
npm ERR! gatsby-plugin-advanced-sitemap@"^2.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/stanislavlyu/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/stanislavlyu/.npm/_logs/2022-11-11T11_34_17_288Z-debug-0.log

A summary of the issue and the browser/OS environment in which it occurs.

To Reproduce

  1. update project to gatsby 5
  2. run npm install
    Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version: 5
  • Node Version: 18
  • OS: mac os m1
  • gatsby-config.js:

"gatsby-plugin-advanced-sitemap" threw an error while running the onPostBuild lifecycle: Cannot read property 'replace' of undefined

Issue Summary

I am trying to get a sitemap for my website, made in Gatsby with strapi, and i tried using this plugin.
Unfortunately, i am getting this error:

 ERROR #11321  PLUGIN

"gatsby-plugin-advanced-sitemap" threw an error while running the onPostBuild lifecycle:

Cannot read property 'replace' of undefined

  208 |           return !exclude.some(function (excludedRoute) {
  209 |             var sourceType = node.__typename ? "all" + node.__typename : source;
> 210 |             var slug = sourceType === "allMarkdownRemark" || sourceType === "allMdx" ? node.fields.slug.replace(/^\/|\/$/, "") : node.slug.replace(/^\/|\/$/, "");
      |                                                                                                                                            ^
  211 |             excludedRoute = typeof excludedRoute === "object" ? excludedRoute : excludedRoute.replace(/^\/|\/$/, ""); // test if the passed regular expression is valid
  212 | 
  213 |             if (typeof excludedRoute === "object") {

File: node_modules\gatsby-plugin-advanced-sitemap\gatsby-node.js:210:140



  TypeError: Cannot read property 'replace' of undefined

This is what i have in gatsby-config:

  siteMetadata: {
    siteUrl: "http://localhost:9000",
  },
plugins: [
 {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
        // 1 query for each data type
        query: `
          {
            allSitePage {
              edges {
                node {
                  id
                  path
                }
              }
            }
          }`,
        mapping: {
          // Each data type can be mapped to a predefined sitemap
          // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name
          // The default sitemap - if none is passed - will be pages
          allSitePage: {
            sitemap: `pages`,
          },
        },
        exclude: [
          `/dev-404-page`,
          `/404`,
          `/404.html`,
          `/offline-plugin-app-shell-fallback`,
          // /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example
        ],
        createLinkInHead: true, // optional: create a link in the `<head>` of your site
        addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
      },
    },
]

I honestly don't know what i am doing wrong... or maybe this plugin can only be used for gatsby + ghost ? or is it that you absolutely need a query for your data and you absolutely need to name the slug slug? i maybe misunderstood something?...

allStrapiArticles {
  edges {
    node {
      id
      article_slug
      article_title
      updatedAt(formatString: "DD MMMM YYYY")
    }
  }
}

Technical details:

  • Gatsby Version:
    Gatsby CLI version: 2.12.117
    Gatsby version: 2.24.86
  • Node Version: v12.19.0
  • OS: Windows 10
  • gatsby-config.js: see up

Thank you so much in advance!!!

Allow for mapping to the same sitemap

I'm currently working on a website and need to create separate sitemaps for each product type. In order to to do this, I need to combine multiple queries into 1 sitemap file. Is there a way to map separate queries to the same sitemap and just have it continue adding rather than replacing?

query: `
{
    allSocks { ... }
    allShoes { ... }
    allSocksDetails { ... }
}`,
mapping: {
    allSocks: {
        sitemap: `socks`
    },
    allShoes: {
        sitemap: `shoes`
    },
    allSocksDetails: {
        sitemap: `socks`
    }
}```

sitemap-pages.xml does not list pages of type page

Description

When you add a page to your blog post and source them in with gatsby-starter-ghost, those pages shoud be listed under sitemap-pages.xml. Currently, they are not shown.

Steps to reproduce

  1. ghost install local to get a fresh ghost installation
  2. add a custom integration to generate a ContentAPI key
  3. Add a page (e.g. /test-page/) in ghost admin with some dummy text
  4. link that page (e.g. /test-page/) to the navigation bar.
  5. clone gatsby-starter-ghost and change .ghost.json to include the keys from step 2.
  6. yarn; gatsby build; gatsby serve
  7. Observe that the added page in 3. does not show under sitemap-pages.xml

Expectation

All pages of a site should be listed under sitemap-pages.xml which is important for SEO.

An option to disable description

Hey,

is there an option to remove/disable the description from generated sitemaps?
"Advanced Sitemap for search engine consumption, by Ghost."

Index page not included in sitemap

Issue Summary

Plugin does not generate src/pages/index. i.e. sitemap is missing the root url.

To Reproduce

Here's my config + gatsby-plugin-sitemap (for comparison):

{
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
        exclude: [`/team`, `/team/`, `/dev-404-page/`, `/404/`, `/404.html`],
        query: `{
          allPublishedTeams {
            edges {
              node {
                id
                slug
                image
              }
            }
          }
        }`,
        mapping: {
          allPublishedTeams: {
            sitemap: `teams`,
          },
        },
      },
    },
    {
      resolve: `gatsby-plugin-sitemap`,
      options: {
        output: `/some-other-sitemap.xml`,
      },
    },

gatsby-plugin-advanced-sitemap generates:
Screen Shot 2020-11-30 at 3 03 13 PM

gatsby-plugin-sitemap spits out:
Screen Shot 2020-11-30 at 3 03 53 PM

Technical details:

  • Gatsby Version: ^2.12.1
  • Node Version: 14.4.0
  • React / Typescript

sitemap-pages.xml is missing all pages except root

Description

When you inspect the page links, e.g. in the starter demo under https://gatsby.ghost.org/sitemap-pages.xml only the root link is listed but all links to pages are missing (e.g. about, rss). Compare that to the standard demo at https://demo.ghost.io/sitemap-pages.xml where those pages are listed.

Details

I checked in the grapghql explorer that the pages are present under the expected path, so I suspect the fix must be made in this repo.

Expectation

All pages of a site should be listed under sitemap-pages.xml which is important for SEO.

Is there a way to include <xhtml:link hreflang /> tag?

Hi, I am trying to include

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <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>
  <url>
    <loc>http://www.example.com/deutsch/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>
  <url>
    <loc>http://www.example.com/schweiz-deutsch/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>
</urlset>

but found no workaround, afaik, this is to tell crawler about localization in our site following this guideline https://support.google.com/webmasters/answer/189077?hl=en

Some conflict with siteMetadata query on config file

During the build process it return me this error:

error Plugin gatsby-plugin-advanced-sitemap returned an error

  Error: Cannot query field "siteUrl" on type "siteMetadata_2".
  GraphQL request (13:7)
  12:     siteMetadata {
  13:       siteUrl
            ^
  14:     }

This is my gatsby-config.js:

module.exports = {
  siteMetadata: {
    title: "Blog Title",
    description: "Blog Description"
  },
  plugins: [
   [... Other_Plugins ... ],
    {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
        // 1 query for each data type
        query: `
            {
              {
                allMarkdownRemark{
                    edges {
                        node {
                            frontmatter {
                                slug
                            }
                        }
                    }
                }
            }
            }`,
        mapping: {
          // Each data type can be mapped to a predefined sitemap
          // Routes can be grouped in one of: posts, tags, authors, pages
	allMarkdownRemark: {
            sitemap: `posts`
          }
        },
        exclude: [
          `/404`
        ],
        createLinkInHead: true
      }
    }
  ]
};

Should I insert the query outside the plugins?

runner.query(...).then is not a function

Issue Summary

yarn build is failing with error:

runner.query(...).then is not a function

To Reproduce

  1. See config below
  2. yarn build
  3. Fail

I'd expect it to work, but get this:

- graphql-runner.js:11 
    [pocketworks-web]/[gatsby]/dist/bootstrap/graphql-runner.js:11:59
  
  - gatsby-node.js:190 runQuery
    [pocketworks-web]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:190:10
  
  - gatsby-node.js:319 _callee2$
    [pocketworks-web]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:319:20
  
  - new Promise
  
  - gatsby-node.js:438 Object.onPostBuild
    [pocketworks-web]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:438:19
  
  - api-runner-node.js:247 runAPI
    [pocketworks-web]/[gatsby]/dist/utils/api-runner-node.js:247:41
  
  - api-runner-node.js:387 Promise.catch.pluginName
    [pocketworks-web]/[gatsby]/dist/utils/api-runner-node.js:387:13
  
  - new Promise
  
  - api-runner-node.js:386 runPlugin
    [pocketworks-web]/[gatsby]/dist/utils/api-runner-node.js:386:10

Technical details:

  • Gatsby Version: 2.15.30
  • Node Version: v13.5.0
  • OS: OSX
  • gatsby-config.js:
require('dotenv').config()

module.exports = {
  siteMetadata: {
    title: `Pocketworks`,
    sieUrl: 'https://pocketworks.co.uk'
  },
  plugins: [
    `gatsby-plugin-netlify`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-react-helmet`,
    {
      resolve: `gatsby-plugin-sass`,
      options: {
        includePaths: ["./src"],
      }
    },
    `gatsby-transformer-remark`,
    {
      resolve: `gatsby-source-datocms`,
      options: {
        apiToken: process.env.DATO_API_TOKEN,
      },
    },
    {
      resolve: `gatsby-source-instagram`,
      options: {
        username: `pocketworks`,
      },
    },
    {
      resolve: `gatsby-plugin-hotjar`,
      options: {
        id: XXXXXXX,
        sv: 6
      },
    },    
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        // The property ID; the tracking code won't be generated without it
        trackingId: "UA-XXXXXXX-2",
        // Defines where to place the tracking script - `true` in the head and `false` in the body
        head: false,
        // Setting this parameter is optional
        anonymize: true,
        // Setting this parameter is also optional
        respectDNT: true,
        // Avoids sending pageview hits from custom paths
        exclude: [],
        // Delays sending pageview hits on route update (in milliseconds)
        pageTransitionDelay: 0,
        // // Enables Google Optimize using your container Id
        // optimizeId: "YOUR_GOOGLE_OPTIMIZE_TRACKING_ID",
        // // Enables Google Optimize Experiment ID
        // experimentId: "YOUR_GOOGLE_EXPERIMENT_ID",
        // // Set Variation ID. 0 for original 1,2,3....
        // variationId: "YOUR_GOOGLE_OPTIMIZE_VARIATION_ID",
        // // Any additional optional fields
        // sampleRate: 5,
        // siteSpeedSampleRate: 10,
        cookieDomain: "pocketworks.co.uk",
      },
    },  
    {
      resolve: "gatsby-plugin-google-tagmanager",
      options: {
        id: "GTM-XXXXXXX",
  
        // Include GTM in development.
        // Defaults to false meaning GTM will only be loaded in production.
        includeInDevelopment: false,
  
        // datalayer to be set before GTM is loaded
        // should be an object or a function that is executed in the browser
        // Defaults to null
        defaultDataLayer: { platform: "gatsby" },  
      },
    },  
    `gatsby-plugin-advanced-sitemap`
  ],
}

Only one page logged in sitemap-pages.xml

Issue Summary

Hello I am trying to generate a sitemap with a what seems to be a basic setup/config. However the sitemap generated has only one page logged whereas I am expecting 600+ pages.

The output I have is a single page URL in sitemap-pages.xml

To Reproduce

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

My query and options seem standard and follow the documentations. Also note that when I do not pass a custom query/options (just by adding 'gatsby-plugin-advanced-sitemap') I get 600+ pages

Technical details:

  • Gatsby Version: 2.32.13
  • Node Version: v14.16.1
  • OS:
  • gatsby-config.js:
    This is my current config in Gatsby
        {
            resolve: 'gatsby-plugin-advanced-sitemap',
            options: {
                query: `
                    {
                        allSitePage {
                            edges {
                                node {
                                    slug: path
                                }
                            }
                        }
                    }`,
                    mapping: {
                        allSitePage: {
                            sitemap: `pages`,
                        },
                    },
                    exclude: [
                        `/404`,
                        `/404.html`,
                    ],
            },
        }

Peformance Problems

Issue Summary

Gatsby maintainer here 👋

Two of our cloud customers saw some pretty long onPostBuild steps in their builds (one OOMs, the other takes 30mins) and we pinpointed it to gatsby-plugin-advanced-sitemap to be the culprit.

I'd like to get some more context on the plugin so that we can solve this problem for them and everyone else using it.

For comparison: On a 10k page ours takes 2sec, yours 10sec. On a 50k page ours takes under 10sec, yours around 300sec.

I'm happy with whatever outcome we'd agree to if the end result is that users won't get a speed penality.

So outcomes could be:

  • The official plugin is sufficient and yours could be deprecated
  • The functionality that causes the slowdown can be removed
  • The slowdown can be fixed while keeping functionality

Attachments

Clipboard 2021-12-08 at 4 27 16 PM (1)

You can open this in Chrome Node Profiler: sitemap-cpu-profile.zip

To Reproduce

  1. Take https://github.com/gatsbyjs/gatsby/tree/master/benchmarks/query-filters-sort and add the sitemap plugin
  2. Run it with > 50k pages
  3. See huge increase in onPostBuild time

Technical details:

  System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 AMD Ryzen 9 3900X 12-Core Processor
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
  Languages:
    Python: 2.7.18 - /usr/bin/python
  Browsers:
    Chrome: 92.0.4515.107
  npmPackages:
    gatsby: ^3.11.0 => 3.11.1
    gatsby-plugin-advanced-sitemap: ^2.0.0 => 2.0.0
  npmGlobalPackages:
    gatsby-cli: 3.8.0
    gatsby-dev-cli: 3.8.0

Undefined URLs in sitemap with Ghost

Issue Summary

When generating a sitemap with Ghost mapping, pages like sitemap-posts.xml, sitemap-tags.xml are rendered with undefined URLs like https://gatsby.ghost.org/undefined

Check your official site URLs demo :)))

https://gatsby.ghost.org/sitemap-posts.xml
https://gatsby.ghost.org/sitemap-tags.xml

To Reproduce

  1. Use Gatsby with Ghost Source
  2. Build an app with a sitemap

Technical details:

  • Gatsby Version: v4.11.1

  • Node Version: v14.17.0

  • OS: macOS

  • gatsby-config.js:

resolve: "gatsby-plugin-advanced-sitemap",
            options: {
                query: "
                {
                    allGhostPost {
                        edges {
                            node {
                                id
                                slug
                                updated_at
                                created_at
                                feature_image
                            }
                        }
                    }
                    allGhostPage {
                        edges {
                            node {
                                id
                                slug
                                updated_at
                                created_at
                                feature_image
                            }
                        }
                    }
                    allGhostTag {
                        edges {
                            node {
                                id
                                slug
                                feature_image
                            }
                        }
                    }
                    allGhostAuthor {
                        edges {
                            node {
                                id
                                slug
                                profile_image
                            }
                        }
                    }
                }",
                mapping: {
                    allGhostPost: {
                        sitemap: "posts",
                    },
                    allGhostTag: {
                        sitemap: "tags",
                    },
                    allGhostAuthor: {
                        sitemap: "authors",
                    },
                    allGhostPage: {
                        sitemap: "pages",
                    },
                },
                createLinkInHead: true,
                addUncaughtPages: true,
            }"

Incorrect header type causing indexing to fail

Summary
If you run any site that uses this plugin through a sitemap validator, an error is sent back indicating that the content type is set to "text/plain" rather than "application/xml".

This is causing google to not index any of the pages that are listed on the sitemap files.

To Reproduce
Test with sitemap checker
https://www.xml-sitemaps.com/

and then even use the example URL provided in the documentation.

https://gatsby.ghost.org/sitemap.xml

or in my personal case

https://blog.useproof.com/sitemap.xml

image

Using a CSV or other data source to exclude urls

I'm building a site for a client, and they want to be able to manage excluding links from the site map. Is there anyway to connect a csv to that field or do a graphql call to WP? I want to keep them out of my gatsby config

Adding `addUncaughtPages` ignores `prefix` and `serializer` options

Issue Summary

If addUncaughtPages option is present in the config any of the prefix or serializer changes are ignored

To Reproduce

  1. Add prefix like
mapping: {
  allSitePage: {
    sitemap: 'pages',
     prefix: '/uk',
  },
},
addUncaughtPages: true,
  1. Build pages
  2. Observe links in sitemap-pages.xml not having /uk prefix in the links

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version: 3.3.0
  • Node Version: v16.13.2
  • OS: MacOS
  • gatsby-config.js: N/A

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Peer dependency compatibility with Gatsby 4.0

Issue Summary

Gatsby 4.0 is out but gatsby-plugin-advanced-sitemap restricts the peer dependency to 3.0. This blocks running npm audit fix, amongst other projects. Is there a plan to update? Looks like renovate is trying to at #198

To Reproduce

See https://github.com/TryGhost/gatsby-plugin-advanced-sitemap/blob/master/package.json#L32

  1. have a package.json with Gatsby 4.0 and gatsby-plugin-advanced-sitemap 2.0
  2. run npm audit fix (using node 16)
  3. see it complain on mismatch on peer dependency

Technical details:

  • Gatsby Version: 4.0
  • Node Version: 16.11.1
  • OS: Mac

Setting `assetPrefix` prefixes xml files but not xsl (results in broken sitemap)

Issue Summary

When setting Gatsby's assetPrefix setting, the outputted files from this plugin end up in different places, with the xml files in a directory inside of public (e.g. /public/my-prefix/sitemap.xml) but the xsl styles file ends up in the root of the public directory. The generated head tag also points to the site root (i.e. without the prefix).

This results in the sitemap being broken when using assetPrefix. Even if navigating to the nested directory (e.g. example.com/my-prefix/sitemap.xml), the link to the styles is then incorrect, so it throws an error and doesn't work.

I am not sure if the files should be prefixed or not (I don't think so), but quite sure it's a bug that the xml and xsl files are outputted in different locations.

To Reproduce

  1. Set Gatsby's assetPrefix path
  2. Configure the plugin
  3. Build

Technical details:

  • Gatsby Version: 2.32.13
  • Node Version: 14.17.1
  • OS: 12.0.1

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v2
  • actions/setup-node v2
  • ubuntu 20.04
npm
package.json
  • @babel/runtime 7.14.0
  • fs-extra 10.1.0
  • lodash 4.17.21
  • pify 5.0.0
  • xml ^1.0.1
  • @babel/cli 7.14.3
  • @babel/core 7.14.3
  • babel-eslint 10.1.0
  • babel-jest 26.6.3
  • babel-preset-gatsby-package 1.5.0
  • cross-env 7.0.3
  • eslint 7.30.0
  • eslint-plugin-ghost 2.5.0
  • eslint-plugin-jest 24.3.6
  • eslint-plugin-react 7.24.0
  • gatsby 3.5.0
  • jest 26.6.3
  • react 17.0.2
  • react-dom 17.0.2
  • gatsby ^3.0.0 || ^4.0.0
  • node >= 12.19.0

  • Check this box to trigger a request for Renovate to run again on this repository

Unable to remove <lastmod/> Tag

Issue Summary

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>https://documentation.elasticpath.com/sitemap-pages.xml</loc>
        <lastmod>2020-07-14T15:57:24.639Z</lastmod>
    </sitemap>
    <sitemap>
        <loc>/commerce-cloud/sitemap.xml</loc>
        <lastmod>2020-07-14T15:57:24.641Z</lastmod>
    </sitemap>
</sitemapindex>

We would like to exclude the tag in the sitemap, but there isn't any configuration for that and we can't edit the XML file directly.

To Reproduce

  1. yarn install the plugin package.
  2. add the plugin in gatsby-config.js
  3. add the additional sitemap URL

Technical details:

  • Gatsby Version: 2.13.51
  • Node Version: 13.8.0
  • OS: MacOS 10.15
  • gatsby-config.js:

Their should be handle if node.slug is undefined or null

Welcome to the Gatsby Plugin Advanced Sitemap GitHub repo! 👋🎉

We use GitHub only for bug reports 🐛

Anything else should be posted to https://forum.ghost.org 👫

For questions related to the usage of Gatsby or GraphQL, please check out their docs at https://www.gatsbyjs.org/ and https://graphql.org/

🚨For support, help & questions use https://forum.ghost.org/c/help
💡For feature requests & ideas you can post and vote on https://forum.ghost.org/c/Ideas

If your issue is with Gatsby.js itself, please report it at the Gatsby repo ➡️ https://github.com/gatsbyjs/gatsby/issues/new.

Issue Summary

A summary of the issue and the browser/OS environment in which it occurs.
const slug = (source === allMarkdownRemark || source === allMdx) ? node.fields.slug.replace(/^/|/$/, ) : node.slug.replace(/^\/|\/$/, )

In gatsby-node.js script at line number 167 their should be handle before replace to avoid error while generating sitemap.xml

To Reproduce

  1. This is the first step
  2. This is the second step, etc.

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version:
  • Node Version:
  • OS:
  • gatsby-config.js:

Serializer: more detailed docs / examples / confirmation it works

*I currently don't use ghost.org–but want to use this plugin for gatsby in general–so I'm posting feedback here.

I can't seem to get serializer working.

In gatsby-config.js I have: (NB: the rest of the plugin settings are fine, including the query for allBlogPost)

                mapping: {
                    allBlogpost: {
                        sitemap: `blogposts`,
                        serializer: (allBlogpost) => {
                            return allBlogpost.edges.map(edge=>{
                                return {
                                    url: 'dummy-url.com',
                                    changefreq: 'weekly',
                                    lastmod: edge.node.lastmod,
                                    priority: 0.8,
                                }
                            })
                        }
                    }
                },

sitemap-blogposts.xml output: (NB: file was generated but no priority, changefreq, i.e. not serializer didn't impact output)

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
    xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
    <url>
        <loc>http://localhost:8000/blog/example-blog-post</loc>
        <lastmod>2021-03-17T18:14:51.012Z</lastmod>
    </url>
</urlset>

1/ Is there an issue with my serializer code? Example/s in the docs would be tres helpful!
2/ Does Serializer only work for ghost.org queries?

Build fail with v1.5.0

Issue Summary

CI/CD with GH Actions encounters an issue during build
image
https://github.com/MontrealPhotoClub/montrealphotoclub.en/pull/121/checks?check_run_id=438650317

 ERROR #11321  PLUGIN

"gatsby-plugin-advanced-sitemap" threw an error while running the onPostBuild lifecycle:

additionalSitemaps.forEach is not a function

  186 |
  187 |   if (additionalSitemaps) {
> 188 |     additionalSitemaps.forEach(function (addSitemap, index) {
      |                        ^
  189 |       if (!addSitemap.url) {
  190 |         throw new Error("URL is required for additional Sitemap: ", addSitemap);
  191 |       }

File: node_modules/gatsby-plugin-advanced-sitemap/gatsby-node.js:188:24

error Command failed with exit code 1.

To Reproduce

  1. Try to build with v1.5.0
  2. Get an error "additionalSitemaps.forEach is not a function"

Technical details:

  • Gatsby Version: 2.19.12

Cannot read property 'replace' of undefined

Issue Summary

A summary of the issue and the browser/OS environment in which it occurs.

To Reproduce

  1. Run gatsby build

Technical details:

I get an error


Cannot read property 'replace' of undefined



  TypeError: Cannot read property 'replace' of undefined
  
  - gatsby-node.js:200 
    [WebApp]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:200:132
  
  - Array.some
  
  - gatsby-node.js:199 
    [WebApp]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:199:27
  
  - Array.filter
  
  - gatsby-node.js:197 _loop
    [WebApp]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:197:53
  
  - gatsby-node.js:226 
    [WebApp]/[gatsby-plugin-advanced-sitemap]/gatsby-node.js:226:7


* Gatsby Version: 2.13.65
* Node Version: 10.15.3
* OS: MacOS
* gatsby-config.js:

`  resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
           // 1 query for each data type
          query: `
          {
            enNews: allPrismicNewsArticlePage(sort: {order: DESC, fields: data___article_date}, filter: {lang: {eq: "en-gb"}}) {
              edges {
                node {
                  uid
                }
              }
            }
            allSitePage {
              edges {
                node {
                  path
                }
              }
            }
            allPrismicAllPressImages {
              edges {
                node {
                  uid
                }
              }
            }
            allImageSharp {
              edges {
                node {
                  fluid {
                    src
                  }
                }
              }
            }
          }
          `,
          mapping: {
              // Each data type can be mapped to a predefined sitemap
              // Routes can be grouped in one of: posts, tags, authors, pages, or a custom name
              // The default sitemap - if none is passed - will be pages
              allSitePage: {
                  sitemap: `pages`,
              },
              enNews: {
                sitemap: `news`,
            },
              allImageSharp: {
                  sitemap: `images`,
              },
          },
          // exclude: [
          //     `/dev-404-page`,
          //     `/404`,
          //     `/404.html`,
          //     /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example
          // ],
          createLinkInHead: false, // optional: create a link in the `<head>` of your site
          addUncaughtPages: false, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
      }`

How can I add a custom page link?

Is it possible to add a custom page link to the sitemap? I want to include the actual home page (the main website link) but I can't

warn Plugin gatsby-plugin-advanced-sitemap is not compatible with your gatsby version 3.1.0

Issue Summary

warn Plugin gatsby-plugin-advanced-sitemap is not compatible with your gatsby version 3.1.0 - It requires gatsby@^2.0.0

To Reproduce

  1. Gatsby build
  2. This is the second step, etc.

Technical details:

  • Gatsby Version: 3.0

can you change package.json to let be compatible with gatsby 3.0?

you probably needs to change the devDependencies in package.json if you have a chance. Thank you

There are instance where the listed sitemap is not the slug

Technical details:

  • Gatsby Version: 2.23.3
  • Node Version: 12.16.1
  • OS: Windows 10
  • gatsby-config.js:

I have this custom plugin that I created from a third party source API.

The gatsby graphql contains slug and parentPath.

However, when I generated the plugin, there are instances that it is not using the slug.

Here are my thoughts. For example,
Slug: "paardenvoer/"
parentPath: "Dieren/Paarden/Paardenvoer/Voer"

Then the sitemap URL will list "Dieren/Paarden/Paardenvoer" where it contains the actual slug "paardenvoer".

Do you have any advice or a tweak in my code to make sure that it is picking up the slug instead of other slugs such as parentPath?

Please check the image for more details.

image

Error querying gatsby-source-graphql plugin

I am using gatsby-source-graphql to query GraphCMS, which nests my data collections under the parent field graphCMS.

{
  graphCMS {
    projects(stage: PUBLISHED) {
      slug
      updatedAt
      publishedAt
    }
    workshops(stage: PUBLISHED) {
      slug
      updatedAt
      publishedAt
    }
  }
}

With no configuration, gatsby-plugin-advanced-sitemap creates a single sitemap-pages.xml that gives me a 404.

I also can't figure out how to map nested data sources, since there's no way to destructure (or perhaps there is?). Nesting objects won't work.

{
  mapping: {
    graphCMS: {
      projects: {
        sitemap: 'projects',
      },
      workshops: {
        sitemap: 'workshops',
      },
    },
  },
}

lastModified not in sitemap output

Issue Summary

The lastModified is not reflected for any url in my sitemap. It always shows the timestamp of the time the sitemap was generated.

To Reproduce

Query

allContentfulBlogPost {
  edges {
    node {
      id
      slug: url
      url
      lastModified: updatedAt
    }
  }
}

Response

{
  "data": {
    "allContentfulPageSystem": {
      "edges": [
        {
          "node": {
            "url": "login",
            "slug": "login",
            "id": "490b991c-********",
            "updatedAt": "2020-03-13T16:22:20.417Z"
          }
        },
        {
          "node": {
            "url": "test",
            "slug": "test",
            "id": "a7437eba-*******",
            "updatedAt": "2020-03-13T16:21:56.027Z"
          }
        }
      }
    }
  }
}

Sitemap.xml

<url>
  <loc>https://example.com/login</loc>
  <lastmod>2020-03-18T23:02:00.593Z</lastmod>
</url>
<url>
  <loc>https://example.com/test</loc>
  <lastmod>2020-03-18T23:02:00.593Z</lastmod>
</url>

I expect every url to use the lastModified field as timestamp, instead it shows the timestamp of the time the sitemap was generated, making every page having the same lastModified field.
I also tried updated_at, updatedAt as field names, but no luck either.

Perhaps it has something to do with these lines, but I'm not entirely sure: https://github.com/TryGhost/gatsby-plugin-advanced-sitemap/blob/master/src/IndexMapGenerator.js#L36-L37

Technical details:

  • Gatsby Version: 2.19.26
  • Plugin version: 1.5.2
  • Node Version: 12.x
  • OS: Linux, MacOS

Make excludes more intuitive

The exclude option is incredibly unintuitive. The examples look like the following:

exclude: [
  `/dev-404-page`,
  `/404`,
  `/404.html`,
  `/offline-plugin-app-shell-fallback`,
  `/my-excluded-page`,
  /(\/)?hash-\S*/, // you can also pass valid RegExp to exclude internal tags for example
],

The above examples make it seem like /dev-404-page would either match a URI exactly or the beginning of it (ie. /dev-404-page would be rejected or /dev-404-page/.* would be rejected).

In reality, the following examples would be rejected:

  • /dev-404-page
  • /aaa/dev-404-page/loremipsum
  • /dev-404-pageandsomeotherstuff

That is really unintuitive.

Can it be an exact match? Or a start of URI match? Otherwise, can we add notes in the README?

Images: 0 for every page

Issue Summary

gatsby-plugin-advanced-sitemap didn't see any images on my page
Should I use any special tags to correctly detect it?

Example image in my code:

<picture>
  <source type="image/webp" srcSet={logo_webp}/>
  <source type="image/jpg" srcSet={logo}/>
  <img src={mafia_logo} alt="Logo"/>
</picture>

Technical details:

  • Gatsby Version: 2.27.3
  • Node Version: 15.3.0
  • OS: Linux (node:latest docker)
  • gatsby-config.js: (without any options)

V2: Ideas and Umbrella ☂

Now that Gatsby 3 has been released, We should also proceed with the Next Major release.

Here are some of the changes that I'm proposing.

Major Breaking Changes

  • Drop Node 10 (EOL April 2021)
    • Remove deprecated API
  • Upgrade to Gatsby 3
  • Typescript?

Features

  • Support for changefreq and priority in XML
  • Allows custom output path for individual sitemap

We can track the progress here.
@aileen

Example of Serializer Output Needed

Does the Serialize function behave the same as https://www.gatsbyjs.com/plugins/gatsby-plugin-sitemap/?
There's no example of what's needed - I'm trying to change the changefreq, priority and lastmod using the serializer but always receive an error on build.

Any docs on what the serializer expects to return would be incredible; I'll write up if I can get this to work.

"gatsby-plugin-advanced-sitemap" threw an error while running the onPostBuild lifecycle:
Cannot read property '__typename' of undefined

    {
      resolve: `gatsby-plugin-advanced-sitemap`,

      options: {
        query: `
        {
          otherPages: allGraphCmsAdditionalPage {
            edges {
              node {
                slug
                updatedAt
              }
            }
          }
          merchants: allGraphCmsMerchant {
            edges {
              node {
                slug
                updatedAt
                offers {
                  id
                }
              }
            }
          }
          categories: allGraphCmsCategory {
            edges {
              node {
                slug
                updatedAt
              }
            }
          }
          allSitePages: allSitePage(filter: {isCreatedByStatefulCreatePages: {in: true}}) {
            edges {
              node {
                id
                slug: path
              }
            }
          }
        }        
      `,
        output: '/sitemap.xml',
        mapping: {
          otherPages: {
            serializer: (edges) => {
              const payLoad = edges.map(({ node }) => {
                return {
                  source: 'otherPages',
                  url: node.slug,
                  changefreq: `yearly`,
                  priority: 0.3,
                  lastmod: node.updatedAt
                }
              })

              console.log('payLoad', payLoad)
              return payLoad
            }
          },
          merchants: {
            serializer: (edges) =>
              edges.map(({ node }) => {
                return {
                  url: node.slug,
                  changefreq: 'daily',
                  priority: node.offers.length > 0 ? 1 : 0.5,
                  lastmod: node.updatedAt
                }
              })
          },
          categories: {
            serializer: (edges) => {
              return edges.map(({ node }) => {
                return {
                  url: node.slug,
                  changefreq: 'weekly',
                  priority: 0.5,
                  lastmod: node.updatedAt
                }
              })
            }
          },
          allSitePages: {
            serializer: (edges) => {
              return edges.map(({ node }) => {
                return {
                  url: node.slug,
                  changefreq: 'weekly',
                  priority: 0.5,
                  lastmod: node.updatedAt
                }
              })
            }
          }
        },
        exclude: [
          `/dev-404-page`,
          `/404`,
          `/404.html`,
          `/out/`,
          `/out/*`
        ],
        createLinkInHead: true // optional: create a link in the `<head>` of your site
      }
    },

siteUrl issues in review env's etc.

Issue Summary

If advanced sitemap isn't deployed, the sitemap won't because of 404d /sitemap.xsl. I manually tried to edit xml file and make url relative rather than absolute (<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>). Maybe this approach would be valid?

To Reproduce

  1. gatsby build
  2. gatsby serve
  3. Go to /sitemap.xml
  4. /sitemap.xsl will fail to load if it is not on production server

Technical details:

  • Gatsby Version: 2.8.2
  • gatsby-config.js: default 'gatsby-plugin-advanced-sitemap'

Empty sitemap when site is not located on root

Issue Summary

When creating a sitemap for a site that is not located on the root, e.g http://example.github.io/my-gatsby-site/, the sitemap is not generated correctly. The my-gatsby-site suffix is missing when inspecting the sitemap. See:
<?xml-stylesheet type="text/xsl" href="//example.github.io/sitemap.xsl"?>

To Reproduce

  1. Add pathPrefix to gatsby config
  2. gatsby build && gatsby serve
  3. Inspect generated sitemap

I would expect that the pathPrefix would be added after the siteUrl so it becomes http://example.github.io/my-gatsby-site/sitemap.xsl instead of http://example.github.io/sitemap.xsl

Adding the pathPrefix to siteUrl in gatsby config makes no difference in generating the sitemap.

Technical details:

  • Gatsby Version: 2.4.2
  • Node Version: 10.15.0
  • OS: macOS High Sierra 10.13.6
  • gatsby-config.js:
module.exports = {
  pathPrefix: '/my-gatsby-site',
  siteMetadata: {
...
    siteUrl: "http://example.github.io/my-gatsby-site/"
  },
...

Exclude excludes more than exact matches

Hey there. It seems the exclude method is not working correctly. When I exclude /team, pages such as /submit-your-team or /request-a-team are excluded as well.

Line 186 of gatsby-node.js is:

return slug.indexOf(excludedRoute) >= 0

/* logged output
{
  excludedRoute: 'team/',
  slug: 'suggest-a-team/',
  match: true,
}
*/

This might be by design, so correct me if I'm wrong 😄 But looks like slug and excludedRoute are transposed. indexOf should return a strict equality match. We get a strict match if we do :

return excludedRoute.indexOf(slug) >= 0

/* logged output
{
  excludedRoute: 'team/',
  slug: 'suggest-a-team/',
  match: false,
}
*/

Note: this fix breaks the default exclusion of /dev-404-page/`, `/404/`, `/404.html.

In case this helps, I'm on "gatsby": "^2.12.1" and here's my config:

    {
      resolve: `gatsby-plugin-advanced-sitemap`,
      options: {
        exclude: [`/team`, `/team/`, `/dev-404-page/`, `/404/`, `/404.html`],
        query: `{
          allPublishedTeams {
            edges {
              node {
                slug
                image
              }
            }
          }
        }`,
        mapping: {
          allPublishedTeams: {
            sitemap: `teams`,
          },
        },
        addUncaughtPages: true,
      },
    },

I'm happy to open a PR for this change. Let me know :)

Google can't parse this sitemap

Issue Summary

I was a bit concerned that if this sitemap was being rendered as a pure HTML file and not as an XML file, Google wouldn't be able to parse it. So I tested this out with Google Search Console, and they can't parse it. I don't see any indication of Google support HTML parsing for sitemaps either.

image

Just to make sure, when I visit my sites /sitemap.xml, it clearly shows the correct page.

Is this purposefully not supported? If so, why is the default sitemap.xml?

Error when running gatsby build with --prefix-paths

Issue Summary

Trying to use this plugin and deploy to Github Pages (using gh-pages)

Errors

[Error: ENOENT: no such file or directory, open 'public/website-gatsby/sitemap.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'public/website-gatsby/sitemap.xml'
}

[Error: ENOENT: no such file or directory, open 'public/website-gatsby/sitemap-pages.xml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'public/website-gatsby/sitemap-pages.xml'
}

To Reproduce

  1. add a pathPrefix key/value to gatsby-config.js
  2. gatsby build --prefix-paths

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

  • Gatsby Version: 2.10.0
  • Node Version: 12.10.0
  • OS: Mac OSX Mojave

Missing nodes cause by lodash merge

Hey @AileenCGN 👋

I came across your plugin as I wanted to split up a sitemap for a client project in pages and posts. After configuring the plugin I noticed some pages were missing in the sitemap. I stepped through the plugin's code and the issue seems to occur in the serializer function on line 239:

const allNodes = _.merge(nodes, pageNodes)

In my case the merge function seems to remove the first 6 elements from nodes (as pageNodes contains 6 entries).

I created a codesandbox with my nodes and pageNodes data before the merge function, showcasing how merge affects the result, as well a proposed solution that seems to work for my use case: https://codesandbox.io/s/strange-yonath-57k0j

  • Gatsby Version: 2.19.41
  • Node Version: 10.16.2
  • OS: macOS Mojave 10.14.4
  • gatsby-config.js:
module.exports = {
  siteMetadata: {
    siteUrl: 'http://localhost:9000',
  },
  plugins: [
    {
      resolve: 'gatsby-source-contentful',
      options: contentfulConfig, // object containing spaceId and accessToken
    },
    'gatsby-transformer-remark',
    'gatsby-plugin-react-helmet',
    {
      resolve: 'gatsby-plugin-sharp',
      options: {
        useMozJpeg: false,
        stripMetadata: true,
        quality: 80,
        defaultQuality: 80,
        maxWidth: 1200,
      },
    },
    {
      resolve: 'gatsby-transformer-remark',
      options: {
        plugins: [
          {
            resolve: 'gatsby-remark-images-contentful',
            options: {
              linkToOriginalImage: false,
              withWebp: true,
              maxWidth: 600,
            },
          },
        ],
      },
    },
    {
      resolve: 'gatsby-plugin-sass',
      options: {
        postCssPlugins: [autoprefixer],
        precision: 5,
      },
    },
    {
      resolve: 'gatsby-plugin-google-tagmanager',
      options: {
        id: 'GTM-5B6L8HD',
      },
    },
    {
      resolve: 'gatsby-plugin-google-analytics',
      options: {
        trackingId: 'UA-38450094-2',
        head: false,
        anonymize: true,
        respectDNT: true,
      },
    },
    {
      resolve: 'gatsby-plugin-advanced-sitemap',
      options: {
        query: `
        {
          posts: allContentfulPages(filter: { isBlogPost: { eq: true } }) {
            edges {
              node {
                id
                slug
                updated_at: updatedAt
              }
            }
          }
          pages: allContentfulPages(filter: { isBlogPost: { ne: true } }) {
            edges {
              node {
                id
                slug
                updated_at: updatedAt
              }
            }
          }
        }`,
        mapping: {
          posts: {
            sitemap: 'posts',
          },
          pages: {
            sitemap: 'pages',
          },
        },
        exclude: [
          '/kitchensink',
          '/dev-404-page',
          '/offline-plugin-app-shell-fallback',
          /(?:test\/)(.*?)/,
        ],
        createLinkInHead: true,
        addUncaughtPages: true
      },
    },
    'gatsby-plugin-robots-txt',
    {
      resolve: 'gatsby-plugin-robots-txt',
      options: {
        host: 'http://localhost:9000',
        sitemap: 'http://localhost:9000/sitemap.xml',
        policy: [{ userAgent: '*', allow: '/' }],
      },
    },
  ],
};

Some pages are missing in the sitemap

I'm using this plugin in my gatsby blog. Everything looks and works fine, except a page that isn't in the sitemap.xml file. It seems that sitemap ignores some pages. How can I troubleshoot this problem or fix it?

blog's home page: https://datanerd.blog
sitemap: https://datanerd.blog/sitemap-pages.xml
the page that I can't see in the sitemap: https://datanerd.blog/data-analysis-with-python-movielens/

gatsby version: 3.4.0
gatsby-plugin-advanced-sitemap: 1.6.0
I haven't added any options (for example to exclude any page) in the gatsby-config file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.