TLDR; sitemap.xml not being generated on GatsbyJS site deployed to subdirectory
Attempting to set up two sites, a primary landing page site, and a gatsby blog.
This is what the redirect looks like on the primary site:
/blog/* https://mysite.netlify.com/blog/:splat 200!
If I navigate to https://mysite.com/blog/ the blog is being proxied correctly. The image assets are not being loaded correctly since they are in a subdirectory instead of public/. For now, I’ve simply added /blog/ in front of all of the image src URL’s as I was not able to get assetPrefix to work. This is a good working temporary solution.
For the blog, I’m using gatsby-ghost-starter, with the following netlify.toml file:
[build]
command = "gatsby build --prefix-paths && cd public && mkdir blog | mv * blog && mv blog/_headers . && mv blog/_redirects ."
publish = "public/"
[template]
incoming-hooks = ["Ghost"]
I’m using pathPrefix to prepend /blog/ to all of the routes.
module.exports = {
pathPrefix: `/blog`,
siteMetadata: {
siteUrl: config.siteUrl,
},
The siteUrl in siteConfig.js is set to: “https://mysite.com/blog” without a trailing slash.
Everything seems to be working alright except for the sitemap and RSS generation. These are the log errors I’m seeing:
error { [Error: ENOENT: no such file or directory, open 'public/blog/sitemap.xml']
11:45:13 AM: errno: -2,
11:45:13 AM: code: 'ENOENT',
11:45:13 AM: syscall: 'open',
11:45:13 AM: path: 'public/blog/sitemap.xml' }
11:45:13 AM: error { [Error: ENOENT: no such file or directory, open 'public/blog/sitemap-pages.xml']
11:45:13 AM: errno: -2,
11:45:13 AM: code: 'ENOENT',
11:45:13 AM: syscall: 'open',
11:45:13 AM: path: 'public/blog/sitemap-pages.xml' }
11:45:13 AM: error { [Error: ENOENT: no such file or directory, open 'public/blog/sitemap-posts.xml']
11:45:13 AM: errno: -2,
11:45:13 AM: code: 'ENOENT',
11:45:13 AM: syscall: 'open',
11:45:13 AM: path: 'public/blog/sitemap-posts.xml' }
11:45:13 AM: error { [Error: ENOENT: no such file or directory, open 'public/blog/sitemap-tags.xml']
11:45:13 AM: errno: -2,
11:45:13 AM: code: 'ENOENT',
11:45:13 AM: syscall: 'open',
11:45:13 AM: path: 'public/blog/sitemap-tags.xml' }
11:45:13 AM: error { [Error: ENOENT: no such file or directory, open 'public/blog/sitemap-authors.xml']
11:45:13 AM: errno: -2,
11:45:13 AM: code: 'ENOENT',
11:45:13 AM: syscall: 'open',
11:45:13 AM: path: 'public/blog/sitemap-authors.xml' }
I’m stumped as to whats causing this.