How to make robots.txt file work for only these things?

Hi. New to Hugo as of 3-4 days ago. For basic HTML on what I am trying to do, I use:

<meta name="robots" content="noarchive">
<meta name="robots" content="notranslate">
<meta name="robots" content="noimageindex">

How do I transfer this for Hugo to understand it? I believe Hugo format is:

User-agent: *
{{ range .Pages }}
Disallow: {{ .RelPermalink }}
{{ end }}

but I’m not sure how to work with this. Thank you. Also, I want this to apply to every page.

Why not add the code to head.html file of your theme?

You mean my HTML code? If so, sure. Will that automatically work for all pages? If not, then how?

Copy the head.html file of your theme to the same path in the root layout’s directory, make the changes, build your site and then check your source code.

Can I do that for the entire theme’s folder? It is so frustrating to make changes on the theme’s directories and then if I want to delete stuff, I have to delete it twice because a lot of stuff I add to the theme’s folders also gets duplicated to public/. Do I need to make a /layouts/ directory then at root, because the only one I have is in my theme’s directory?

This is my root directory. /layouts/ is in the theme’s one. And then I go into /themes/ and choose my current theme’s folder (JuiceBar) and the rest of my folders are here:

I wouldn’t recommend it. You copy the files you need to modify only. Create the same path in the root folder as in your theme. I recommend checking Hugo’s docs for more info.

So anytime changes are made to the site, I need to guess if I can do it in my root directory or theme’s directory (because the same folders exist in both sometimes)? Why is it setup like that?

And ok, so I should copy my theme’s /layouts/ folder to root you’re saying? But at that point, why have doubles of everything? And so, if I put the /layouts/ folder at my root, I no longer need to use the one in /themes/?

Better question: which folders here can I move to my root folder and delete from /themes/?


See @irkode’s comment above.

I did. I read some stuff there but don’t really get it yet. Much appreciated if you told me which ones I can move to root & delete from /themes/ so I can get this site going.

One basic concept:

Themes are just like normal Hugo sites, They have mostly the same folders and should be considered static. I’m pretty sure I read something about that in the docs.

Maybe reading Template lookup order | Hugo

So If you want to change the one part of a theme the normal way would be to copy the file in question to the matching location in your site and adjust it there.

files duplicated in site and theme are taken from the site.

If you play the Quick start | Hugo you will get a site using a theme and can play around.

I just don’t get why there needs to be so many duplicate files at all. Ok, so for header.html, for example, I copied that from my themes folder and to my root because I wanted to edit it. Do I now delete the header.html from themes and keep it at root or keep both, or does it not matter?

Because at that point, why not move everything from /themes/ to the root so that I don’t have to go back-and-forth and can just edit anything at root if I want to instead of making duplicate files that take up space?

exactly one of the points why I pointed you to read more. maybe the external resources is better than the quite technical stuff in the docs.

If you create your site your site by yourself, than you do not need to have anything in the themes folder. If you use a foreign theme, there’s no need to copy stuff around.


So if I use a theme (which I assume everyone does?) then essentially use /themes/theme/ as my root and store everything there?

Because I do use a theme, and I just got done moving most stuff from /themes/theme/ to my root folder & deleting files I didn’t need from the theme, and my local server is still fine and nothing broke. All I need from a theme is exactly that…a theme (colors, layouts, etc). The other main stuff I feel like should just be in root.

my last answer:

you are so fast to re ask some question but got still bunch of docs to read before.

just two links from a simple search in here:

and this one from the guideline