Hurray! You created all the components and styling for your beautiful and performant Next.js website. What now?
There are some key files you want ...
For further actions, you may consider blocking this person and/or reporting abuse
Another example for a next js site. I've adjusted it slightly to also handle sub-folders:
Very nice! I've made some changes in my project, perhaps this is of any use to someone.
In the walkSync method I used the 'dir' parameter to replace
pages/
. This makes the method reusable for any other paths such as posts.Also, by using an early return I filtered out any files that do not compile to an actual file:
Thanks! I think there's a bug in the code:
${Object.keys(pathsObj).map(
path =>
<url>
<loc>https://embiem.me${path}</loc>
<lastmod>${
formatDate(new Date(pathsObj[path].lastModified))
}</lastmod>
</url>
)}
Should be:
${Object.keys(pathsObj).map(
path =>
<url>
<loc>https://embiem.me${path}</loc>
<lastmod>${
formatDate(new Date(pathsObj[path].lastModified))
}</lastmod>
</url>
).join("")}
The original version is outputting commas between each XML element.
Hello Martin,
I am trying to add the sitemap and robots.txt files to my web NextJs app. I follow your post and I generated the two files without any problems but what is the next step to make accessible via URL the file in production ?
The two files are in the Out directory but they are not accessible in the url online.
Sorry for my bad english, I hope you will understand my problem.
Charlotte
Hey. This really depends on your deployment setup. As long as all files in the out folder are pushed to your static file host, you should be good.