Commit graph

180 commits

Author SHA1 Message Date
Peter van Dijk
fe84cc218e
commands: Clarify that create or install a theme are two options 2024-04-25 14:38:22 +02:00
Bjørn Erik Pedersen
38f68cd162 commands: Adjust completions 2024-04-11 15:34:26 +02:00
Ville Skyttä
a67650b6f7 completion: Improve existing argument completions, add many more
Do not offer filenames to arguments not taking one, complete arguments
of options taking resource kinds, directory names, --logLevel, release
--step, config and new --format.

As an internal refactoring, use higher level functions to set flag
completions.  SetAnnotation works, but is more verbose than
alternatives, and uses bash specific wording.

While at it, move setting completions next to flag definitions
consistently.

Remove superfluous --destination completer setting, which is already
set elsewhere.
2024-04-11 15:34:26 +02: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
Joe Mooring
27b22cd87e commands/new: Remove format flag from new content cmd
Fixes #11462
2023-10-30 09:02:26 +01:00
Bjørn Erik Pedersen
ebaa733d45 Make sure resources directory isn't created in hugo new theme
Fixes #11382
2023-08-23 22:50:35 +02:00
Joe Mooring
b6538532f4 commands/new: Embed site and theme skeletons
The skeletons are used when creating new sites and themes with the CLI.

Closes #11358
2023-08-21 10:38:22 +02:00
hugoreleaser
239f2e2c99 releaser: Prepare repository for 0.117.0-DEV
[ci skip]
2023-08-01 07:36:32 +00:00
hugoreleaser
3e1ea030a5 releaser: Bump versions for release of 0.116.1
[ci skip]
2023-08-01 07:24:54 +00:00
hugoreleaser
5a7e0da84e releaser: Bump versions for release of 0.116.0
[ci skip]
2023-07-31 10:28:28 +00:00
hugoreleaser
0dbe0f1a07 releaser: Prepare repository for 0.116.0-DEV
[ci skip]
2023-07-20 07:02:18 +00:00
hugoreleaser
dc95245212 releaser: Bump versions for release of 0.115.4
[ci skip]
2023-07-20 06:49:57 +00:00
hugoreleaser
79f15be5b0 releaser: Prepare repository for 0.116.0-DEV
[ci skip]
2023-07-13 16:23:50 +00:00
hugoreleaser
5c2e014a51 releaser: Bump versions for release of 0.115.3
[ci skip]
2023-07-13 16:11:34 +00:00
hugoreleaser
91b02091a5 releaser: Prepare repository for 0.116.0-DEV
[ci skip]
2023-07-08 17:19:03 +00:00
hugoreleaser
8966424e0e releaser: Bump versions for release of 0.115.2
[ci skip]
2023-07-08 17:06:56 +00:00
hugoreleaser
d912491f2d releaser: Prepare repository for 0.116.0-DEV
[ci skip]
2023-07-03 17:39:56 +00:00
hugoreleaser
857374e693 releaser: Bump versions for release of 0.115.1
[ci skip]
2023-07-03 17:28:25 +00:00
hugoreleaser
67caf50698 releaser: Bump versions for release of 0.115.0
[ci skip]
2023-06-29 15:56:39 +00:00
Andreas Deininger
635cc346ce commands: Fix panic when running hugo new theme without theme name
Closes #11162.
2023-06-28 16:20:54 +02:00
Mos Roshanavand
12646750aa Print help message when triggered with no flags 2023-06-28 14:58:36 +02:00
Andreas Deininger
793e38f5ce
commands: Fix help message for hugo new theme
Closes #11161.
2023-06-28 09:30:27 +02:00
Joe Mooring
019299b0b0 commands: Enable format flag with hugo new site
Fixes #11155
2023-06-24 20:26:54 +02:00
hugoreleaser
9df2ec7988 releaser: Bump versions for release of 0.114.0
[ci skip]
2023-06-19 17:01:43 +00:00
hugoreleaser
085c1b3d61 releaser: Bump versions for release of 0.113.0
[ci skip]
2023-06-05 15:04:51 +00:00
hugoreleaser
536bf71abe releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-06-02 07:19:22 +00:00
hugoreleaser
ea3c95a7b0 releaser: Bump versions for release of 0.112.7
[ci skip]
2023-06-02 07:07:11 +00:00
hugoreleaser
8c7a4e995b releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-06-01 09:15:08 +00:00
hugoreleaser
2ca0fcc448 releaser: Bump versions for release of 0.112.6
[ci skip]
2023-06-01 09:03:29 +00:00
hugoreleaser
d47225ce9e releaser: Bump versions for release of 0.112.5
[ci skip]
2023-05-29 06:43:02 +00:00
hugoreleaser
cd59216de4 releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-05-28 13:15:07 +00:00
hugoreleaser
e285153d7f releaser: Bump versions for release of 0.112.4
[ci skip]
2023-05-28 13:04:00 +00:00
Bjørn Erik Pedersen
43f1282e73 commands: Reinstate some of the removed build flags (e.g. --theme) to new and mod
Fixes #11018
2023-05-28 12:55:44 +02:00
Bjørn Erik Pedersen
901cd970db commands: Re-introduce the -f shorthand for hugo new site
Fixes #11015
2023-05-27 16:56:54 +02:00
Bjørn Erik Pedersen
f86b5f70a6 commands: Move the --format flag to only the commands that support it
Fixes #11022
2023-05-27 16:56:54 +02:00
hugoreleaser
3297b395d8 releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-05-24 14:54:43 +00:00
hugoreleaser
ba6f74e404 releaser: Bump versions for release of 0.112.3
[ci skip]
2023-05-24 14:42:50 +00:00
hugoreleaser
5adc837904 releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-05-24 10:57:20 +00:00
hugoreleaser
f89108f2b1 releaser: Bump versions for release of 0.112.2
[ci skip]
2023-05-24 10:45:31 +00:00
hugoreleaser
99407c39ba releaser: Prepare repository for 0.113.0-DEV
[ci skip]
2023-05-23 17:38:44 +00:00
hugoreleaser
7c90c19d28 releaser: Bump versions for release of 0.112.1
[ci skip]
2023-05-23 17:26:16 +00:00
hugoreleaser
0a95d6704a releaser: Bump versions for release of 0.112.0
[ci skip]
2023-05-23 08:14:20 +00:00
Bjørn Erik Pedersen
85b13c105a Add --format to hugo config
Now default to TOML.
2023-05-22 20:26:02 +02:00
Bjørn Erik Pedersen
8a69ccbb00 commands: Improve the common build flag handling
Updates #10947
2023-05-17 22:13:29 +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
satotake
ab5ce59894 Fix usage description 2022-09-08 15:35:11 +02:00
satotake
7d40da876c Add --force to hugo new
Closes #9243
2022-09-08 15:35:11 +02:00
Bjørn Erik Pedersen
9185e11eff Reimplement archetypes
The old implementation had some issues, mostly related to the context (e.g. name, file paths) passed to the template.

This new implementation is using the exact same code path for evaluating the pages as in a regular build.

This also makes it more robust and easier to reason about in a multilingual setup.

Now, if you are explicit about the target path, Hugo will now always pick the correct mount and language:

```bash
hugo new content/en/posts/my-first-post.md
```

Fixes #9032
Fixes #7589
Fixes #9043
Fixes #9046
Fixes #9047
2021-10-16 15:22:03 +02:00
Bjørn Erik Pedersen
7d1f806ecb commands: Don't fail on template errors on go mod graph etc.
Fixes #8942
2021-08-31 22:16:12 +02:00
Bjørn Erik Pedersen
022c479551
hugofs: Make FileMeta a struct
This commit started out investigating a `concurrent map read write` issue, ending by replacing the map with a struct.

This is easier to reason about, and it's more effective:

```
name                                  old time/op    new time/op    delta
SiteNew/Regular_Deep_content_tree-16    71.5ms ± 3%    69.4ms ± 5%    ~     (p=0.200 n=4+4)

name                                  old alloc/op   new alloc/op   delta
SiteNew/Regular_Deep_content_tree-16    29.7MB ± 0%    27.9MB ± 0%  -5.82%  (p=0.029 n=4+4)

name                                  old allocs/op  new allocs/op  delta
SiteNew/Regular_Deep_content_tree-16      313k ± 0%      303k ± 0%  -3.35%  (p=0.029 n=4+4)
```

See #8749
2021-07-15 17:14:26 +02:00