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

sitemap.xml and robots.txt example #4163

Merged
merged 4 commits into from
May 25, 2018
Merged

Conversation

klyburke
Copy link
Contributor

This example app shows you how to set up sitemap.xml and robots.txt files for proper indexing by search engine bots.

@sergiodxa
Copy link
Contributor

Thanks for the example, just a question, how is this different to https://github.com/zeit/next.js/tree/canary/examples/root-static-files? Could we improve the already existent example instead of creating a new one?

@brikou
Copy link
Contributor

brikou commented May 5, 2018

Why not just do something like this within your package.json?

postbuild: "cp robots.txt sitemap.xml .next",

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me

@timneutkens timneutkens merged commit 3f6834d into vercel:canary May 25, 2018
@klyburke
Copy link
Contributor Author

Thanks @timneutkens !

@kachkaev
Copy link
Contributor

kachkaev commented Jun 8, 2018

@klyburke just curious: how do you make sure that when posts update, sitemap is updated too? Looks like at the momemt sitemap is generated on server launch only.

@klyburke
Copy link
Contributor Author

@kachkaev good question. I've updated the example and added a description to the README to address it.

The current example does not automatically update sitemap when the posts are changed (by changing n=5 in posts.js).

This app, in which posts are fetched from a database, does update sitemap after the cacheTime.

lependu pushed a commit to lependu/next.js that referenced this pull request Jun 19, 2018
This example app shows you how to set up sitemap.xml and robots.txt files for proper indexing by search engine bots.
timneutkens pushed a commit that referenced this pull request Sep 4, 2018
I simplified the example by removing `.eslintrc.js` and related packages, as well as `nodemon`. 

I also added a description in the README to address the question by @kachkaev in the original pull request (#4163).
@spencersmb
Copy link
Contributor

Just installed this and everything is working locally except for the robots.txt doesn't seem to be getting generated. I can console.log the path and it's displaying the correct path in the static folder, but the .get Route is not writing the file. Please advise if you can, thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants