DEV Community

Discussion on: How to implement a robots.txt file in a Nuxt project — Nuxt 2.10

Collapse
 
kp profile image
KP

@siliconmachine what is the advantage of using this module over simply adding a robots.txt file in static/robots.txt ?

Collapse
 
saul profile image
Saul Hardman • Edited

@kp in my experience, the biggest benefit of using a module such as @nuxtjs/robots presents itself when you pass it a function rather than a static object. This means that you can decide based on your data whether or not a path should be allowed or disallowed.

I parse a index: true | false value from the front-matter of my markdown articles and use that to dynamically generate my robots.txt on nuxt generate.

I hope that provides a good example?

Collapse
 
kp profile image
KP

@saul just seeing your reply as I’ve not been on here. thanks for the explanation! Would this make a difference for universal mode sites, does the module provide the same benefits?

Thread Thread
 
saul profile image
Saul Hardman

I'd imagine so, but only during the nuxt build step. I don't think it would be able to update based on data changes alone whilst the application is running via nuxt start. Looking into the codebase itself or posting an issue with a question should get you a clearer answer though 👍

Thread Thread
 
kp profile image
KP

Sounds good thanks @saul