Am using netlify-cms on my development machine and would like to disable it in deployment on netlify. I added a following redirect rule in netlify.toml to hide hugo’s static/admin folder. However the redirect doesn’t work.
from = "/admin"
to = "/404.html"
status = 404
I am not sure if I understand your problem correctly. Is the rule not working?
Also, if the admin page exists and you need to redirect, I think the status should be 301 and not 404.
The redirect rule doesn’t work even with 301.
Wouldn’t it be easier to add admin/index.html to your gitignore file, or exclude it from build in your Hugo configuration?
It would need the
force = true because the path exists. Read here: Redirects and rewrites | Netlify Docs
@tomrutgers It seems Hugo allow you only to exclude markdown files from builds.
I’m no Hugo expert but I believe you can do something like
ignorefiles = [ "admin/.*" ] or
ignorefiles = [ "admin/.index.html" ] as long as you put it before the