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

Not working correctly with gatsby-plugin-sitemap #11

Open
wmitsuda opened this issue Mar 4, 2019 · 6 comments
Open

Not working correctly with gatsby-plugin-sitemap #11

wmitsuda opened this issue Mar 4, 2019 · 6 comments

Comments

@wmitsuda
Copy link

wmitsuda commented Mar 4, 2019

I'm trying to generate sitemaps using the plugin gatsby-plugin-sitemap, but the generated URLs are like this: https://website.com./page/

Note the trailing dot after the domain. The gatsby-plugin-sitemap is before the gatsby-plugin-ipfs in gatsby-config.js just for information.

Not sure if there is something that can be done from gatsby-plugin-ipfs side.

@satazor
Copy link
Contributor

satazor commented Mar 4, 2019

Hello! Are you using Gatsby 2 and the latest version of this plugin? I’m asking because we no longer use . but instead use __GATSBY_IPFS_PATH_PREFIX__

We replace all those occurrences with the correct path based on the depth of it, meaning that the URL inside the sitemap should be ok.

Also be sure that the plugin is the last one from the plugin list.

I may help you out if the project is public; if it is, send me your project repo and I can take a look.

@wmitsuda
Copy link
Author

wmitsuda commented Mar 4, 2019

Hi, yes, I'm using gatsby 2.1.4 and gatsby-plugin-ipfs 2.0.2.

The gatsby-config.js contains the pathPrefix: 'GATSBY_IPFS_PATH_PREFIX' and all links are correctly generated. The exception is the file sitemap.xml that is generated by the gatsby-plugin-sitemap.

I'm sure the behavior is caused by the combination of gatsby-plugin-ipfs + gatsby-plugin-sitemap because if I disable gatsby-plugin-ipfs, but maintain the prefix-path, the URL content in sitemap.xml is generated as https://website.com/__GATSBY_IPFS_PATH_PREFIX__/page/

@satazor
Copy link
Contributor

satazor commented Mar 4, 2019

Understood. So, what you want is a way for this plugin to replace __GATSBY_IPFS_PATH_PREFIX__ with something else for certain files, in your case, with /.

With that in mind, the best way is to implement an option where you pass an array of custom transforms, where each transform is something like: { patterns: [‘sitemap.xml’], replacement: ‘/‘ }.

This would resolve your use-case and many others as well.

Are you willing to do a PR that implements that option? Thanks!

@satazor
Copy link
Contributor

satazor commented Mar 13, 2019

@wmitsuda bump.

@wmitsuda
Copy link
Author

@satazor Hi, sorry for the delay.. I thought I'd have some time to take a look at the code, but I hadn't yet...

@i001962
Copy link

i001962 commented May 22, 2019

I believe this is an issue of the order of the plugins are executed in the gatsby-config of your project.

This plugin uses onpostbuild which means it really should run after all other plugins have done their thing. I don't mean to come across as an authority as I'm only 1 year into gatsby on side projects.

Sooo...I'm not 100% certain but IF this plugin were listed below the sitemap plugin in gatsby-config you may not get this error - but you will likely have an invalid sitemap (if I'm reading this plugin's code correctly as it seems like this plugin is also making changes onPrebootstrap.

I'm thinking this should really be two plugins -one for the onprebootstrap and one for the post build because the onprebootstrap will not have run before the sitemap plugin if this plugin is listed last in your gatsby-config.

I could be totally wrong here but thought I'd chime in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants