# Gatsby advanced sitemap, serializer proper usage

**URL:** <https://forum.ghost.org/t/gatsby-advanced-sitemap-serializer-proper-usage/22563>\
**Category:** Developer help\
**Created:** [May 8, 2021, 8:02pm UTC](https://forum.ghost.org/t/gatsby-advanced-sitemap-serializer-proper-usage/22563 "2021-05-08T20:02:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Milivojevic](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ivan_milivojevic/32/13114_2.png) [@Ivan\_Milivojevic](https://forum.ghost.org/u/Ivan_Milivojevic)\
**Post date:** [May 8, 2021, 8:02pm UTC](https://forum.ghost.org/t/gatsby-advanced-sitemap-serializer-proper-usage/22563/1 "2021-05-08T20:02:22Z")

</div>

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 {
                      id
                      slug
                      updated_at: updatedAt
                    }
                  }
                }
              }
            `,
            mapping: {
              allBlogPostDe: {
                sitemap: `pages-de`,
                serializer: edges => {
                  return edges.map(({ node }) => {
                    const urlPath = node.slug.split("")[0] === "/" ? `de${node.slug}` : `de/${node.slug}`

                    return {
                      url: `${site_url}${urlPath}`,
                      lastmodISO: node.updated_at,
                    }
                  })
                },
              },
            },
            exclude: [
              `/dev-404-page`,
              `/404`,
              `/404.html`,
              `/offline-plugin-app-shell-fallback`,
            ],
            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](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

---

<div class="post-metadata">

**Author:** ![snibbo71](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/snibbo71/32/14079_2.png) [@snibbo71](https://forum.ghost.org/u/snibbo71)\
**Post date:** [July 13, 2021, 1:53pm UTC](https://forum.ghost.org/t/gatsby-advanced-sitemap-serializer-proper-usage/22563/2 "2021-07-13T13:53:50Z")

</div>

Crickets…

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…

---

<div class="post-metadata">

**Author:** ![snibbo71](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/snibbo71/32/14079_2.png) [@snibbo71](https://forum.ghost.org/u/snibbo71)\
**Post date:** [July 13, 2021, 4:03pm UTC](https://forum.ghost.org/t/gatsby-advanced-sitemap-serializer-proper-usage/22563/3 "2021-07-13T16:03:28Z")

</div>

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

[https://www.gitmemory.com/issue/TryGhost/gatsby-plugin-advanced-sitemap/150/803198644](https://www.gitmemory.com/issue/TryGhost/gatsby-plugin-advanced-sitemap/150/803198644)

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 🙂

Hopefully this helps anyone else.

For example;

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

```
