Gatsby advanced sitemap, serializer proper usage

Hi, I really need some explanation about the proper usage of serializer inside the Gatsby plugin for advanced sitemaps. I am using Contentful as my CMS, gatsby 2.24.80, node 12.18.3, advanced sitemap is 1.6.0. My current setup in gatsby-config.js is looking like this:

          resolve: `gatsby-plugin-advanced-sitemap`,
          options: {
            query: `
                allBlogPostDe: allContentfulBlogPost(filter: {node_locale: {eq: "de-DE"}}) {
                  edges {
                    node {
                      updated_at: updatedAt
            mapping: {
              allBlogPostDe: {
                sitemap: `pages-de`,
                serializer: edges => {
                  return{ node }) => {
                    const urlPath = node.slug.split("")[0] === "/" ? `de${node.slug}` : `de/${node.slug}`

                    return {
                      url: `${site_url}${urlPath}`,
                      lastmodISO: node.updated_at,
            exclude: [
            createLinkInHead: true,
            addUncaughtPages: true, // add pages that are not caught by queries and mapping under `sitemap-pages.xml`

My question is how to use this Serializer properly because with this setup I get the following error:

Cannot read property ‘__typename’ of undefined

When I remove the serializer I get the sitemap generated on the /sitemap-pages-de.xml without errors, but because I can’t use the prefix added for locale, it will look the same as urls for english version (those doesn’t have any prefix). So, what am I missing here in the code I really don’t know to make this custom with url prefix in sitemap. Example: http://localhost:9001/de/my-blog-post

Also format of updatedAt field is in ISO format that is why I used the lastmodISO. That is also another question: Is this supported by your plugin?

Thanks a lot in advance because I am really hitting the wall now. In your readme file there is no mention about the example of serializer and its custom logic. There is example for non-advanced plugin but that one doesn’t support multiple sitemaps which I need.

Thanks , Ivan


I’ve got a similar issue and can’t find any documentation around the serializer to get it to work. I’m clearly doing something wrong, but with no guidance from the docs it’s difficult to know what to do…

So although I don’t generally reply to my own comments, I have found this;

And implementing the code in the same way the author of that has, I now have a sitemap which is modified to suit my URL scheme and is all working nicely :slight_smile:

Hopefully this helps anyone else.

For example;

allWpPage: {
            sitemap: `pages`,
            serializer: ( edges ) => {
              const siteMapEntries = [];
              edges.forEach(edge => {
                edge.node.slug = edge.node.slug + ".html";
              return siteMapEntries;