How to customise watch files list for hugo server to include dots files . during server mode (content development) while not compiling it as an output file in production mode?
I had successfully developed a Go-compatible string processing Hugo theme. At the moment, to use this module effectively, one has to write in a .content.html instead of the conventional _index.html. Hugo server does not watch any changes for dot files.
Current workaround is to manually nudge (e.g. write emptily in vim) the _index.html in a separate terminal when I want to render the site during development.
I attempted --poll argument but no avail.
For the reason why not to use _index.html:
The module is entirely a different beast: it writes Go compatible html template file (no Hugo specific shortcode all over the places).
To avoid miscommunications. Easier to document and direct customers to use Hugo and the module.
It has its own processing capability that can parse Go template syntax.
Prohibits users from using Hugo’s shortcode; supporting point 2.
Hugo’s role is meant to only compile all the content of a given directory as it is while the theme do the data processing (theme as its own data structure parsed from hugo) and rendering.
The file watcher still detects changes[1] to those excluded files, but they are not transferred to public/ when you build the site.
I’m not sure that if this is the expected behavior, but you can take advantage of it for now. I guess this could change at some point in the future, but there are many bigger fish to fry. ↩︎
If you exclude the files, you will exclude them from existence for both server-mode and compilation-mode, thus even with my parser, it couldn’t find the file on the virtual FS.
No problem. I tried a bunch of regex glob with your idea.
The new ‘problem’ is with the excludeFiles. The moment I activate it, all the excluded files did not appear on both server-mode and compilations where the new source file _content.html went missing → nothing left to read.
Judging by the design, I believe this is working as expected at least in UNIX context (mount to override).
You need config/_default and config/production configurations directories.
Name your custom content with watchable and traceable naming prefix but not conflicting with the main bundle file (e.g. _index.html). My recommendation is using double underscore (e.g. __name.extension ).
Define your usual site-level configs in the _default/config.toml (_default version).
Inside your production/config.toml, only add the ignoreFiles field for extending the _default configurations. If we follow the double underscore naming prefix, the regex value should be:
ignoreFiles = [
'(__.*)',
]
This will let Hugo track all the underlying data files during development while not building it into output files in compilation.
Updating question because the linked reference context is actively changing. See Screenshot for the subject matter discussed: