Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined URLs in sitemap with Ghost #219

Open
eDubrovsky opened this issue Apr 5, 2022 · 6 comments
Open

Undefined URLs in sitemap with Ghost #219

eDubrovsky opened this issue Apr 5, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@eDubrovsky
Copy link

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,
            }"
@yogeshkotadiya yogeshkotadiya added the bug Something isn't working label Apr 6, 2022
@yogeshkotadiya yogeshkotadiya self-assigned this Apr 6, 2022
@kloh-fr
Copy link

kloh-fr commented May 7, 2022

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 #150.

@kloh-fr
Copy link

kloh-fr commented Dec 4, 2022

#234

@julrich
Copy link

julrich commented Apr 14, 2023

This seems to be fixed, but is still unreleased. Any plans on cutting a release? Demo URLs are also still broken / exhibiting this behavior...

@yogeshkotadiya
Copy link
Collaborator

@julrich I do not have permission to release a package.
@aileen Can you please help here?

@Willis0826
Copy link

Willis0826 commented Aug 4, 2023

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. 😉

@nirajtrt
Copy link

We are facing same issue tried above solutions but its not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants