gatsby-plugin-advanced-sitemap
gatsby-plugin-advanced-sitemap copied to clipboard
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
- Use Gatsby with Ghost Source
- 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,
}"
I faced the same issue with posts coming from WordPress source and I made it work using serializer
option.
{
resolve: 'gatsby-plugin-advanced-sitemap',
options: {
query: `
{
allWpPost(filter: { status: { eq: "publish" } }) {
edges {
node {
id
slug
}
}
}
}`,
mapping: {
allWpPost: {
sitemap: 'blog-articles',
serializer: (edges) => {
const siteMapEntries = [];
edges.forEach((edge) => {
edge.node.slug = '/blog/' + edge.node.slug;
siteMapEntries.push(edge);
});
return siteMapEntries;
},
},
},
},
},
Note: it is necessary to specifically use edge.node
instead of simply edge
to make it work.
Credits to andrewdever who gave the hint in https://github.com/TryGhost/gatsby-plugin-advanced-sitemap/issues/150.
#234
This seems to be fixed, but is still unreleased. Any plans on cutting a release? Demo URLs are also still broken / exhibiting this behavior...
@julrich I do not have permission to release a package. @aileen Can you please help here?
I verified that fix #234 did work in my case. It would be great to see this fix released. As a workaround, you can patch it by yourself. 😉
We are facing same issue tried above solutions but its not working.