This is a bit niche, but I thought it might help someone and it was too long to comment:
## noindex date archives ##
location ~ "^(.*)/[0-9]{4}/([0-9]{2}/)?([0-9]{2}/)?$" {
try_files $uri $uri/ /index.php?$args;
set $robots "noindex, nofollow, nosnippet, noarchive";
}
We had been trying to force noindex "date archives "in WordPress for our SlickStack project, and after a lot of testing this seems to do the trick perfectly.
The problem is that we didn't want to noindex potential blog posts like:
https://example.com/2020/03/25/interesting-story-about-ducks/
So, in this case the $
at the end of the location match regex is crucial, otherwise it would noindex any blog post or content that is prefixed by those date parameters! Also the ?
right after the (groupings) mean that they are optionally matched, which makes this snippet pretty powerful.
It will noindex URLs like these:
https://example.com/2020/
https://example.com/2020/03/
https://example.com/2020/03/25/
...but not URLs like the example blog post above, which might have these prefixes.