Skip to content

Commit 1df06ca

Browse files
committed
✨ Implement Page bundling and image handling
This commit is not the smallest in Hugo's history. Some hightlights include: * Page bundles (for complete articles, keeping images and content together etc.). * Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`. * Processed images are cached inside `resources/_gen/images` (default) in your project. * Symbolic links (both files and dirs) are now allowed anywhere inside /content * A new table based build summary * The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below). A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory: ```bash ▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render" benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64% ``` Fixes gohugoio#3651 Closes gohugoio#3158 Fixes gohugoio#1014 Closes gohugoio#2021 Fixes gohugoio#1240 Updates gohugoio#3757
1 parent 02f2735 commit 1df06ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+5303
-3058
lines changed

Gopkg.lock

+102-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
revision = "v1.1.0"
2222

2323
[[constraint]]
24-
branch = "master"
25-
name = "github.com/dchest/cssmin"
24+
name = "github.com/disintegration/imaging"
25+
revision = "v1.2.4"
2626

2727
[[constraint]]
2828
name = "github.com/magefile/mage"
@@ -116,6 +116,10 @@
116116
name = "github.com/stretchr/testify"
117117
version = "1.1.4"
118118

119+
[[constraint]]
120+
branch = "master"
121+
name = "github.com/olekukonko/tablewriter"
122+
119123
[[constraint]]
120124
name = "github.com/yosssi/ace"
121125
version = "0.0.5"

commands/benchmark.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func benchmark(cmd *cobra.Command, args []string) error {
5353
return err
5454
}
5555

56-
c, err := newCommandeer(cfg)
56+
c, err := newCommandeer(cfg, false)
5757
if err != nil {
5858
return err
5959
}
@@ -84,7 +84,7 @@ func benchmark(cmd *cobra.Command, args []string) error {
8484

8585
t := time.Now()
8686
for i := 0; i < benchmarkTimes; i++ {
87-
if err = c.resetAndBuildSites(false); err != nil {
87+
if err = c.resetAndBuildSites(); err != nil {
8888
return err
8989
}
9090
}

commands/commandeer.go

+15-6
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ import (
1818
"github.com/gohugoio/hugo/deps"
1919
"github.com/gohugoio/hugo/helpers"
2020
"github.com/gohugoio/hugo/hugofs"
21+
src "github.com/gohugoio/hugo/source"
2122
)
2223

2324
type commandeer struct {
2425
*deps.DepsCfg
2526
pathSpec *helpers.PathSpec
2627
visitedURLs *types.EvictingStringQueue
2728

29+
staticDirsConfig []*src.Dirs
30+
2831
serverPorts []int
2932

3033
configured bool
@@ -44,21 +47,25 @@ func (c *commandeer) PathSpec() *helpers.PathSpec {
4447
return c.pathSpec
4548
}
4649

47-
func (c *commandeer) languages() helpers.Languages {
48-
return c.Cfg.Get("languagesSorted").(helpers.Languages)
49-
}
50-
5150
func (c *commandeer) initFs(fs *hugofs.Fs) error {
5251
c.DepsCfg.Fs = fs
5352
ps, err := helpers.NewPathSpec(fs, c.Cfg)
5453
if err != nil {
5554
return err
5655
}
5756
c.pathSpec = ps
57+
58+
dirsConfig, err := c.createStaticDirsConfig()
59+
if err != nil {
60+
return err
61+
}
62+
c.staticDirsConfig = dirsConfig
63+
5864
return nil
5965
}
6066

61-
func newCommandeer(cfg *deps.DepsCfg) (*commandeer, error) {
67+
func newCommandeer(cfg *deps.DepsCfg, watching bool) (*commandeer, error) {
68+
cfg.Watching = watching
6269
l := cfg.Language
6370
if l == nil {
6471
l = helpers.NewDefaultLanguage(cfg.Cfg)
@@ -68,5 +75,7 @@ func newCommandeer(cfg *deps.DepsCfg) (*commandeer, error) {
6875
return nil, err
6976
}
7077

71-
return &commandeer{DepsCfg: cfg, pathSpec: ps, visitedURLs: types.NewEvictingStringQueue(10)}, nil
78+
c := &commandeer{DepsCfg: cfg, pathSpec: ps, visitedURLs: types.NewEvictingStringQueue(10)}
79+
80+
return c, nil
7281
}

0 commit comments

Comments
 (0)