Hello, I’m working in the Visual Code environment attempting to make changes to a Hugo directory (https://github.com/HatExperiment/Vitto.git). Whenever I make a change, specifically to the index.html in the Public folder, then run hugo serve, the project regenerates the deleted code. When I run the code in VS debug, the code runs correctly and the code isn’t regenerated, it’s only on running the hugo command. I cannot pinpoint where the code is being regenerated from and attempted to delete the Public folder before rerunning hugo serve, but it just generated the public folder altogether. Any help would be appreciated!
Of course. Whatever HTML you see in public
is most probably generated by Hugo whenever you run it – from the Markdown sources, that’s how Hugo works.
Change the MD files instead.
And make your repo public if you want people to see your code.
Why? You should make the changes in your template or markdown files.
Thanks for the headsup! That’s good info to have, I’m glad hugo is doing what it’s supposed to. Whoops, updated the directory to be public. I’m specifically attempting to get rid of the body text version of the following, just want it in the bootstrap nav menu at top (currently, it shows up on the site landing page in the body, and at the top of the page)
About
<h2><a href="/contact/">Contact</a></h2>
<h2><a href="/events/">Events</a></h2>
<h2><a href="/images/">Images</a></h2>
<h2><a href="/watchandlisten/">Watch And Listen</a></h2>
When I did a search for it in my code, only saw it in the index.html. Can’t determine the source it’s pulling from
EDIT: appears I don’t have a .md for my homepage at all
As I said: the HTML is generated by Hugo from your markdown files. Obviously, you can’t find the HTML you’re looking for anywhere else but in the index.html.
Having said that: Your index.html is generated by the template themes/mytheme/layouts/_default/home.html
. Check that out.
And start by reading and digesting the documentation, eg on templates. Your issues result from a fundamental lack of understanding about the working of Hugo.
Also, you should exclude public
from your Github repository as (some of) it will be regenerated by every Hugo run.
I found that home.html was ranging through the content and delivering it on the homepage:
{{ .Content }}
{{ range site.RegularPages }}
{{ .LinkTitle }}
{{ .Summary }}
{{ end }}
Likely a result of me following a tutorial blindly. I removed the ranging and it took out the portion I was looking to remove. Thank you for the support
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.