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.
- Navigate to
themes/$YOUR_THEME/source
(e.g.themes/cactus/source
) and create an empty file namedrobots.txt
(e.g.touch robots.txt
) - Configure your
robots.txt
as needed - Build the project (with
hexo generate
,yarn build
,npm run build
, … ) - Check whether the file is in the output, which by default should be a directory named
public
- Deploy the site (with
hexo deploy
or viarsync
)
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
.