Add an example how to add robots.txt or sitemap.xml
See original GitHub issueEdit by Maintainers
Root level files are supported in Next.js 9.1 and newer.
Create the robots.txt
file in the public/
directory.
For example:
pages/index.js
public/robots.txt
Note the public
folder is on the same level as the pages
folder, not inside of it!
Read more in the docs: https://nextjs.org/docs/basic-features/static-file-serving
There’s a closed issue related to this without a clear answer: https://github.com/zeit/next.js/issues/226
It’s kind of closed in favor of the Programmatic API so I guess I should implement that with custom server?)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:33 (12 by maintainers)
Top Results From Across the Web
Add Your Sitemap To Your Robots.txt File
Step #1: Locate Your Sitemap URL · Step #2: Locate Your Robots.txt File · Step #3: Add Sitemap Location To Robots.txt File.
Read more >How to Add Sitemaps to Robots.txt?
2.1 Login to Your WordPress Website ; 2.2 Navigate to Edit Robots.txt ; 2.3 Add Sitemap URL in Your Robots.txt ; 2.4 Save...
Read more >How to Add Sitemap to Robots.txt (Full Guide)
Step 1: Determine Your Sitemap URL · Step 2: Locate Your Robots.txt File · Step 3: Add a Sitemap to the Robots.txt File....
Read more >Create and submit a robots.txt file | Google Search Central
Learn how to create a robots.txt file, see examples, and explore robots.txt ... The site's sitemap file is located at https://www.example.com/sitemap.xml .
Read more >Robots.txt sitemap: how to reference it?
It's a best practice to always reference your XML sitemap(s) in your robots.txt file. Here are the rules of engagement: ... On top...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another way of doing this: put
robots.txt
into/static
folder, then add this to your server config:Next.js now has a
public/
folder that mounts files at the root automatically! Createpublic/robots.txt
and you’re done!