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

Where to place Sitemap? #872

Closed
vianneylancres opened this issue Apr 28, 2017 · 4 comments
Closed

Where to place Sitemap? #872

vianneylancres opened this issue Apr 28, 2017 · 4 comments

Comments

@vianneylancres
Copy link

Hey Guys!

First off - thank you for gatsbyJs! I joined a project where they are using gatsby and I got used to it pretty fast.

Now I was trying to make use of a sitemap. I already created a sitemap.xml file, that is stored in /pages. When I go to Google's Search Console and try to add the sitemap to my entity, I can't seem to find the right path.

I tried:
xyz.com/sitemap.xml
xyz.com/pages/sitemap.xml
xyz.com/public/sitemap.xml

I even created a "public" folder manually and added the sitemap to that folder which did not work either. Am I missing some permissions or settings somewhere?

Can you please help a not-so-much-of-a-developer-guy out?
Thank you

@KyleAMathews
Copy link
Contributor

How do you build and deploy your site to production right now?

@emilyaviva
Copy link
Contributor

emilyaviva commented Apr 28, 2017

The way I do this kind of thing, as a data point, is to copy the file to its destination in /public as part of a post-build script in my gatsby-node.js. As an example, here's that file from a Gatsby starter I made:

var fs = require('fs-extra')
var path = require('path')
var buildFeed = require('./scripts/buildFeed')

exports.postBuild = (pages, callback) => {
  console.log('Building Atom feed')
  // Build RSS feed.
  buildFeed(pages, callback)
  // Copy favicon.
  fs.copySync(path.join(__dirname, '/favicon'), path.join(__dirname, '/public/favicon'))
  // Next callback.
  callback()
}

The reason why I do it this way is because all the contents of /public are auto-generated each time the gatsby build script is run, so anything you manually put into it has to be done after Gatsby does its build process. That's what the postBuild hook is good for.

@hugmanrique
Copy link
Contributor

It would be neat to have a static directory inside of src which autocopies everything, a webpack filter could be used to do this automatically.

@jbolda
Copy link
Contributor

jbolda commented Jun 3, 2017

@vianneylancres, looks like you have a few solutions. This will also be easier in the 1.0 branch. Closing for now unless you have other questions.

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

5 participants