skip to content
blog.metters.dev

How to add a robots.txt file to your hexo blog

/ 1 min read

This is going to be a short one, promise!

It might be logical for many, but it wasn’t to me: How to add a robots.txt to my site, which is generated by hexo. So I googled. And the best I could find was this video. Because I prefer to read on technical information (it is searchable!), I decided to summarise it here. It is really trivial.

  1. Navigate to themes/$YOUR_THEME/source (e.g. themes/cactus/source) and create an empty file named robots.txt (e.g. touch robots.txt)
  2. Configure your robots.txt as needed
  3. Build the project (with hexo generate, yarn build, npm run build, … )
  4. Check whether the file is in the output, which by default should be a directory named public
  5. Deploy the site (with hexo deploy or via rsync)

To be honest, step 1 alone would have been enough to explain how to add that robots.txt, but it would have felt too short.


UPDATE This is also applicable for other files that you might want to add to your root folder, like security.txt.


Resources