Some re-generation questions

Hi I am fairly new to Hugo, loving it, but still in a learning mode.

hugo env:
hugo v0.126.2+extended linux/amd64 BuildDate=2024-07-18T00:00:00+00:00 VendorInfo=Fedora:0.126.2-3.fc41
GOOS=“linux”
GOARCH=“amd64”
GOVERSION=“go1.23rc1”
github.com/sass/libsass=“3.6.5”
github.com/webmproject/libwebp=“v1.3.2”

I use

hugo server -D --disableFastRender

to generate a site.

I noticed the following:

I installed a theme using

hugo new theme THEMENAME

This theme has some sample post folders and files under the /themes/themename/content/posts/ directory.

When I deleted this /themes/themename/content/posts/ directory, the posts still appear in /public.

So far, I have only learned to exit the server using Ctrl-C and restarting it, to try and re-generate the site. Doing this, in this case, does not remove the /posts directory in the public folder.

It is easy of course to manually delete the /posts directory in the public folder, but I am wondering if there is some regeneration command that I should be using instead?

I searched the forum and did not find any issues that I thought was similar.

I looked thru the server options and did not see any that I thought would help with this issue. But I am a noob so maybe I do not understand all the options.

I also did an interwebs search and did not find anything.

Also, I wanted to change the number of words in the summaries in list.html.

I put

summary = 10

in the site’s hugo.toml and the site was automatically regenerated and showed very shortened summaries.

Then I removed this line from the site’s hugo.toml and put it in the theme’s hugo.toml.

This did not work - the summaries were not shortened from the default of 70.

I concluded from this that

summary = 10

can only be but in site’s hugo.toml.

So I removed it from the theme’s hugo.toml and put it back in the site’s hugo.toml.

This time however, the summaries were not shortened, even though this line worked before.

Now, since this line did not work in the site’s hugo.toml, I wonder if my conclusion that this line does not work in the theme’s hugo.toml is incorrect. IE this line is now not working in either file.

Again I exit the server using Ctrl-C and restarting it, to try and re-generate the site but this did not help.

I also have had this issue occasionally when making some other changes in other files.

I did find:

Why isn’t Hugo’s development server detecting file changes?
In its default configuration, Hugo’s file watcher may not be able detect file changes when:

    Running Hugo within Windows Subsystem for Linux (WSL/WSL2) with project files on a Windows partition
    Running Hugo locally with project files on a removable drive
    Running Hugo locally with project files on a storage server accessed via the NFS, SMB, or CIFS protocols

In these cases, instead of monitoring native file system events, use the --poll command line flag. For example, to poll the project files every 700 milliseconds, use --poll 700ms.

In the FAQ - those situations do not apply to me but I did try:

hugo server -D --disableFastRender --poll 5000ms

but this did not help either.

So again I am wondering what I am doing wrong, eg is there some re-generation command that I should be using.

Any help is much appreciated :slight_smile:

This is expected. Whether you run hugo or hugo server, the site is published to the publishDir, typically public in the root of your project.

From https://gohugo.io/getting-started/usage/#build-your-site

If you have a static directory in the root of your project, even if it is empty, you can add the --cleanDestinationDir command-line flag. This will clear the publishDir, but only if you have a static directory (see #8433).

You need to specify this in the project’s configuration file. I would be quite annoyed if a theme author were able to control this setting. Some configuration settings can be set at the theme level, but most cannot. See https://gohugo.io/configuration/introduction/#merge-configuration-settings.

I’m not sure what you did wrong. Perhaps you added the setting within (below) a table instead of placing it in the root.

1 Like

@jmooring - Thank you once again for your quick and comprehensive support and clearing up my questions.
I will double check what I might be doing wrong with putting the summary setting back in the site’s config file.

You can also set this in your site configuration to reduce command-line noise:
https://gohugo.io/configuration/all/#cleandestinationdir

1 Like

Thanks, I will check out cleanDestinationDir :slight_smile:

Could I add one related question?
If I create a post that is meant to be published immediately, and IS generated in the /public folder and then change the post to be published in the future, does that mean Hugo will not remove this post from /public?
Thanks again for any help.

Yes, it does:
https://gohugo.io/getting-started/usage/#draft-future-and-expired-content

1 Like

@jmooring - Thank you for confirming this. Seems obvious and hence a stupid question in restrospect. Thanks though for once again your quick and comprehensive support. Please send me the bill :wink:

1 Like

Nope. It’s a good question.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.