Commit Graph

24 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 861ede6d10 cache/filecache: Don't prune used cache entries with mixed-case dir names
On case-insensitive filesystems, entries created before we started lowercasing
the content paths in v0.123 are the same file as today's lowercased cache key,
and were removed on every hugo --gc.

Fixes #15101

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-26 11:40:27 +02:00
Bjørn Erik Pedersen f8b5fa09a6 Fix prevention of direct symlink reads in resources.Get
* Note for themes, this is only an issue for themes stored locally, e.g. below `themes/...`. Themes mounted as modules from GitHub gets symlinks stripped away.
* Thas was also not an issue for file reading walking one or more directories.
* This is an regression introduced in `v0.123.0`.
2026-05-13 10:06:43 +02:00
Bjørn Erik Pedersen b55d452e46 testing: Simplify line ending handling in tests 2026-03-28 19:48:28 +01:00
Bjørn Erik Pedersen 157bfddda5 testing: Make commands tests pass in Go 1.26.1 2026-03-06 12:23:25 +01:00
Bjørn Erik Pedersen b358a65c8b Upgrade to Go 1.26 2026-02-12 15:34:33 +01:00
Bjørn Erik Pedersen 9045797d5f server: Fix panic when the server browser error handler tried to use a config in a state of flux
I tried and failed to create a test for this, but I have tested this manually.,

Fixes #14470
2026-02-05 20:11:48 +01:00
Bjørn Erik Pedersen 00c4228f61 testscripts: Move server tests to own folder
See #14439
2026-01-27 18:27:47 +01:00
Bjørn Erik Pedersen e2e64aeec5 Fix server rebuilds on editing content with Chinese terms
Fixes #14240
2025-12-05 15:53:48 +01:00
Bjørn Erik Pedersen b9b304a126 testing: Port integration tests to new templates structure
As introduced in  v0.146.0. Keep some legecy test to preserve backwards compatibility.
2025-11-27 12:00:15 +01:00
Bjørn Erik Pedersen 747cf4ad65 modules: Add support for direct version module imports in hugo.toml
Fixes #13964
2025-09-07 22:47:25 +02:00
Bjørn Erik Pedersen 6927e6f048 deps: Upgrade github.com/rogpeppe/go-internal v1.13.1 => v1.14.1
Closes #13449
2025-02-26 14:43:03 +01:00
Christian Oliff 78178d0c2a all: Typo fixes 2024-03-15 17:25:52 +01:00
Bjørn Erik Pedersen 7285e74090 all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning
There are some breaking changes in this commit, see #11455.

Closes #11455
Closes #11549

This fixes a set of bugs (see issue list) and it is also paying some technical debt accumulated over the years. We now build with Staticcheck enabled in the CI build.

The performance should be about the same as before for regular sized Hugo sites, but it should perform and scale much better to larger data sets, as objects that uses lots of memory (e.g. rendered Markdown, big JSON files read into maps with transform.Unmarshal etc.) will now get automatically garbage collected if needed. Performance on partial rebuilds when running the server in fast render mode should be the same, but the change detection should be much more accurate.

A list of the notable new features:

* A new dependency tracker that covers (almost) all of Hugo's API and is used to do fine grained partial rebuilds when running the server.
* A new and simpler tree document store which allows fast lookups and prefix-walking in all dimensions (e.g. language) concurrently.
* You can now configure an upper memory limit allowing for much larger data sets and/or running on lower specced PCs.
We have lifted the "no resources in sub folders" restriction for branch bundles (e.g. sections).
Memory Limit
* Hugos will, by default, set aside a quarter of the total system memory, but you can set this via the OS environment variable HUGO_MEMORYLIMIT (in gigabytes). This is backed by a partitioned LRU cache used throughout Hugo. A cache that gets dynamically resized in low memory situations, allowing Go's Garbage Collector to free the memory.

New Dependency Tracker: Hugo has had a rule based coarse grained approach to server rebuilds that has worked mostly pretty well, but there have been some surprises (e.g. stale content). This is now revamped with a new dependency tracker that can quickly calculate the delta given a changed resource (e.g. a content file, template, JS file etc.). This handles transitive relations, e.g. $page -> js.Build -> JS import, or $page1.Content -> render hook -> site.GetPage -> $page2.Title, or $page1.Content -> shortcode -> partial -> site.RegularPages -> $page2.Content -> shortcode ..., and should also handle changes to aggregated values (e.g. site.Lastmod) effectively.

This covers all of Hugo's API with 2 known exceptions (a list that may not be fully exhaustive):

Changes to files loaded with template func os.ReadFile may not be handled correctly. We recommend loading resources with resources.Get
Changes to Hugo objects (e.g. Page) passed in the template context to lang.Translate may not be detected correctly. We recommend having simple i18n templates without too much data context passed in other than simple types such as strings and numbers.
Note that the cachebuster configuration (when A changes then rebuild B) works well with the above, but we recommend that you revise that configuration, as it in most situations should not be needed. One example where it is still needed is with TailwindCSS and using changes to hugo_stats.json to trigger new CSS rebuilds.

Document Store: Previously, a little simplified, we split the document store (where we store pages and resources) in a tree per language. This worked pretty well, but the structure made some operations harder than they needed to be. We have now restructured it into one Radix tree for all languages. Internally the language is considered to be a dimension of that tree, and the tree can be viewed in all dimensions concurrently. This makes some operations re. language simpler (e.g. finding translations is just a slice range), but the idea is that it should also be relatively inexpensive to add more dimensions if needed (e.g. role).

Fixes #10169
Fixes #10364
Fixes #10482
Fixes #10630
Fixes #10656
Fixes #10694
Fixes #10918
Fixes #11262
Fixes #11439
Fixes #11453
Fixes #11457
Fixes #11466
Fixes #11540
Fixes #11551
Fixes #11556
Fixes #11654
Fixes #11661
Fixes #11663
Fixes #11664
Fixes #11669
Fixes #11671
Fixes #11807
Fixes #11808
Fixes #11809
Fixes #11815
Fixes #11840
Fixes #11853
Fixes #11860
Fixes #11883
Fixes #11904
Fixes #7388
Fixes #7425
Fixes #7436
Fixes #7544
Fixes #7882
Fixes #7960
Fixes #8255
Fixes #8307
Fixes #8863
Fixes #8927
Fixes #9192
Fixes #9324
2024-01-27 16:28:14 +01:00
Lars Lehtonen 26a8ec207f Fix handling of dropped error in test 2023-11-29 09:37:26 +01:00
Bjørn Erik Pedersen 79a17d9e55 Fix tests for Go 1.21.1
Fixes #11450
2023-09-14 13:09:45 +02:00
Bjørn Erik Pedersen 24b1be45c1 Go 1.21 Upgrade
Fixes #11351
2023-08-23 21:49:27 +02:00
Bjørn Erik Pedersen b3f10556f0 Use os.UserCacheDir as first fallback if cacheDir is not set
We will now try

1. cacheDir (or, commonly set in environment as `HUGO_CACHEDIR`)
2. if on Netlify we use `/opt/build/cache/hugo_cache/`
3. os.UserCacheDir
4. A temp dir

Storing the cache, especially the module cache, in a temporary idea has had lots of hard to debug issues, especially on MacOS,
which this commit tries to fix.

This should also make it easier to locate the Hugo cache:

>UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own
application-specific subdirectory within this one and use that.
>
>On Unix systems, it returns $XDG_CACHE_HOME as specified by
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it
returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache.
>
>If the location cannot be determined (for example, $HOME is not defined), then it will return an error.

Fixes #11286
Fixes #11291
2023-07-27 20:59:47 +02:00
Bjørn Erik Pedersen 0f921ace6f Fix hugo mod vendor for modules with hugo.toml
Fixes #11221
2023-07-08 16:08:46 +02:00
Oleksandr Redko 4c46f9400b all: Replace deprecated ioutil with io and os 2023-06-01 17:52:21 +02:00
Bjørn Erik Pedersen fd099331ec Fix Processed images count regression for multiple languages
Fixes #11002
2023-05-28 12:55:44 +02:00
Bjørn Erik Pedersen e96cdfe966 Don't create the public folder unless needed
Fixes #11031
2023-05-28 12:55:44 +02:00
Bjørn Erik Pedersen 241b21b0fd Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code.

Also,

* Lower case the default output format names; this is in line with the custom ones (map keys) and how
it's treated all the places. This avoids doing `stringds.EqualFold` everywhere.

Closes #10896
Closes #10620
2023-05-16 18:01:29 +02:00
Bjørn Erik Pedersen b886fa46bb Revert "Add benchmark for building docs site"
We already have a lot of site building benchmarks. The main problem with adding the "Hugo site docs" to the list is that it cannot easiliy  be compared to any previous release, because its content/template/whatever has changed.

This reverts commit 837e084bbe.
2020-10-17 00:37:42 +02:00
Cameron Moore 837e084bbe Add benchmark for building docs site 2020-10-16 21:13:39 +02:00