Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Type should return empty when no type set and .Section returns empty #6760

Closed
bep opened this issue Jan 16, 2020 · 1 comment · Fixed by #6777
Closed

.Type should return empty when no type set and .Section returns empty #6760

bep opened this issue Jan 16, 2020 · 1 comment · Fixed by #6777
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Jan 16, 2020

This is in line with the documentation. The implementation returns page in this case, which is some very old code which also messes up with the template resolution logic.

@bep bep added the Bug label Jan 16, 2020
@bep bep added this to the v0.63 milestone Jan 16, 2020
@bep bep self-assigned this Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 16, 2020
bep added a commit to bep/hugo that referenced this issue Jan 19, 2020
bep added a commit to bep/hugo that referenced this issue Jan 19, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML templates without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
bep added a commit to bep/hugo that referenced this issue Jan 19, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
bep added a commit to bep/hugo that referenced this issue Jan 20, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
bep added a commit to bep/hugo that referenced this issue Jan 20, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
bep added a commit to bep/hugo that referenced this issue Jan 21, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
bep added a commit to bep/hugo that referenced this issue Jan 21, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
bep added a commit to bep/hugo that referenced this issue Jan 21, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
bep added a commit to bep/hugo that referenced this issue Jan 21, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others::

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.0ms ± 1%    10.5ms ± 1%  -19.55%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.1ms ± 1%    10.6ms ± 0%  -18.91%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.5ms ± 0%    42.8ms ± 1%   -7.96%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.3ms ±12%    47.9ms ± 5%     ~     (p=0.200 n=4+4)
SiteNew/Deep_content_tree-16        76.5ms ± 1%    70.2ms ± 1%   -8.27%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      42.7ms ± 1%    36.8ms ± 1%  -13.93%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         57.4ms ± 0%    52.4ms ± 0%   -8.64%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.78%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.00MB ± 0%  -44.34%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.1MB ± 2%    14.1MB ± 0%  -26.48%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.6MB ± 0%    68.9MB ± 0%   -2.42%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.0MB ± 0%    31.2MB ± 0%  -15.77%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.5MB ± 0%    10.5MB ± 0%  -39.88%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.96%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.17%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        335k ± 1%      269k ± 0%  -19.53%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          400k ± 0%      313k ± 0%  -21.66%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.05%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.46%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
bep added a commit to bep/hugo that referenced this issue Jan 22, 2020
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others:

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good, but I have repeated the below with ca. the same result. Compared to master:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.1ms ± 1%    10.5ms ± 1%  -19.34%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.0ms ± 0%    10.7ms ± 1%  -18.05%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.4ms ± 2%    43.1ms ± 1%   -7.15%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.2ms ± 2%    47.8ms ± 1%   -8.30%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        77.9ms ± 1%    70.9ms ± 1%   -9.01%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      43.0ms ± 0%    37.2ms ± 1%  -13.54%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         58.2ms ± 1%    52.4ms ± 1%   -9.95%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.70%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.01MB ± 0%  -44.20%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.3MB ± 1%    14.1MB ± 0%  -26.91%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.7MB ± 0%    69.0MB ± 0%   -2.40%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.1MB ± 0%    31.2MB ± 0%  -15.94%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.6MB ± 0%    10.6MB ± 0%  -39.92%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.99%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.18%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        336k ± 1%      269k ± 0%  -19.90%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          401k ± 0%      313k ± 0%  -21.79%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.17%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.55%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
@bep bep closed this as completed in #6777 Jan 22, 2020
@bep bep closed this as completed in c6d650c Jan 22, 2020
jakejarvis pushed a commit to jakejarvis/hugo that referenced this issue Mar 5, 2021
This more or less completes the simplification of the template handling code in Hugo started in v0.62.

The main motivation was to fix a long lasting issue about a crash in HTML content files  without front matter.

But this commit also comes with a big functional improvement.

As we now have moved the base template evaluation to the build stage we now use the same lookup rules for `baseof` as for `list` etc. type of templates.

This means that in this simple example you can have a `baseof` template for the `blog` section without having to duplicate the others:

```
layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── blog
    └── baseof.html
```

Also, when simplifying code, you often get rid of some double work, as shown in the "site building" benchmarks below.

These benchmarks looks suspiciously good, but I have repeated the below with ca. the same result. Compared to master:

```
name                              old time/op    new time/op    delta
SiteNew/Bundle_with_image-16        13.1ms ± 1%    10.5ms ± 1%  -19.34%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    13.0ms ± 0%    10.7ms ± 1%  -18.05%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      46.4ms ± 2%    43.1ms ± 1%   -7.15%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            52.2ms ± 2%    47.8ms ± 1%   -8.30%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        77.9ms ± 1%    70.9ms ± 1%   -9.01%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      43.0ms ± 0%    37.2ms ± 1%  -13.54%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         58.2ms ± 1%    52.4ms ± 1%   -9.95%  (p=0.029 n=4+4)

name                              old alloc/op   new alloc/op   delta
SiteNew/Bundle_with_image-16        3.81MB ± 0%    2.22MB ± 0%  -41.70%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16    3.60MB ± 0%    2.01MB ± 0%  -44.20%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16      19.3MB ± 1%    14.1MB ± 0%  -26.91%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16            70.7MB ± 0%    69.0MB ± 0%   -2.40%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16        37.1MB ± 0%    31.2MB ± 0%  -15.94%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16      17.6MB ± 0%    10.6MB ± 0%  -39.92%  (p=0.029 n=4+4)
SiteNew/Page_collections-16         25.9MB ± 0%    21.2MB ± 0%  -17.99%  (p=0.029 n=4+4)

name                              old allocs/op  new allocs/op  delta
SiteNew/Bundle_with_image-16         52.3k ± 0%     26.1k ± 0%  -50.18%  (p=0.029 n=4+4)
SiteNew/Bundle_with_JSON_file-16     52.3k ± 0%     26.1k ± 0%  -50.16%  (p=0.029 n=4+4)
SiteNew/Tags_and_categories-16        336k ± 1%      269k ± 0%  -19.90%  (p=0.029 n=4+4)
SiteNew/Canonify_URLs-16              422k ± 0%      395k ± 0%   -6.43%  (p=0.029 n=4+4)
SiteNew/Deep_content_tree-16          401k ± 0%      313k ± 0%  -21.79%  (p=0.029 n=4+4)
SiteNew/Many_HTML_templates-16        247k ± 0%      143k ± 0%  -42.17%  (p=0.029 n=4+4)
SiteNew/Page_collections-16           282k ± 0%      207k ± 0%  -26.55%  (p=0.029 n=4+4)
```

Fixes gohugoio#6716
Fixes gohugoio#6760
Fixes gohugoio#6768
Fixes gohugoio#6778
@github-actions
Copy link

github-actions bot commented Feb 9, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant