Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gohugoio/hugo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.125.7
Choose a base ref
...
head repository: gohugoio/hugo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.126.0
Choose a head ref
  • 14 commits
  • 82 files changed
  • 4 contributors

Commits on May 8, 2024

  1. releaser: Prepare repository for 0.126.0-DEV

    [ci skip]
    bep committed May 8, 2024
    Copy the full SHA
    b1bf0bf View commit details

Commits on May 10, 2024

  1. markup/goldmark: Support extras extension

    Enables inclusion of these HTML elements in Markdown:
    
    - Inserted Text (++inserted++)
    - Mark Text (==marked==)
    - Subscript (H~2~O)
    - Superscript (1^st^)
    jmooring authored and bep committed May 10, 2024
    Copy the full SHA
    ca9a77e View commit details
  2. tpl/tplimpl: Retain query string and fragment in render-image.html

    Closes #12468
    jmooring authored and bep committed May 10, 2024
    Copy the full SHA
    6dfeb9f View commit details
  3. livereload: Improve the livereload script build and update to v4.0.2

    This script has very infrequent updates, but just copy pasting the minified source creates some potential trust issues.
    
    This JS will now be pulled from a Git version and both the unminified and minified version gets written to disk.
    
    This way it should be easier to reason about changes in the future.
    
    To upgrade, change the commit hash and run `mage generate`.
    
    Closes #12451
    Closes #6290
    bep committed May 10, 2024
    Copy the full SHA
    d02f062 View commit details
  4. build(deps): bump golang.org/x/image from 0.15.0 to 0.16.0

    Bumps [golang.org/x/image](https://github.com/golang/image) from 0.15.0 to 0.16.0.
    - [Commits](golang/image@v0.15.0...v0.16.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/image
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and bep committed May 10, 2024
    Copy the full SHA
    6e83d00 View commit details
  5. build(deps): bump golang.org/x/net from 0.24.0 to 0.25.0

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.24.0 to 0.25.0.
    - [Commits](golang/net@v0.24.0...v0.25.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and bep committed May 10, 2024
    Copy the full SHA
    ee26e69 View commit details

Commits on May 14, 2024

  1. tpl/tplimpl: Improve locale value in opengraph.html

    Closes #12480
    jmooring authored and bep committed May 14, 2024
    Copy the full SHA
    87ab7f7 View commit details
  2. create/skeletons: Remove superfluous language code fallback

    Closes #12479
    jmooring authored and bep committed May 14, 2024
    Copy the full SHA
    55dea41 View commit details
  3. Create pages from _content.gotmpl

    Closes #12427
    Closes #12485
    Closes #6310
    Closes #5074
    bep committed May 14, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    bep Bjørn Erik Pedersen
    Copy the full SHA
    e2d66e3 View commit details
  4. resources/images: Handle NaN EXIF latitude and longitude

    Fixes #12490
    jmooring authored and bep committed May 14, 2024
    Copy the full SHA
    6dbbe6d View commit details
  5. tpl/tplimpl: Plainify title and description in schema.html

    Closes #12432
    jmooring authored and bep committed May 14, 2024
    Copy the full SHA
    92290aa View commit details
  6. tpl/tplimpl: Plainify title and description in twitter_cards.html

    Closes #12433
    Improves #10900
    jmooring authored and bep committed May 14, 2024
    Copy the full SHA
    74ab839 View commit details
  7. docs: Regen docshelper

    bep committed May 14, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    bep Bjørn Erik Pedersen
    Copy the full SHA
    2661402 View commit details
  8. releaser: Bump versions for release of 0.126.0

    [ci skip]
    bep committed May 14, 2024
    Copy the full SHA
    32c9675 View commit details
Showing with 6,650 additions and 525 deletions.
  1. +1 −1 commands/hugobuilder.go
  2. +4 −4 commands/server.go
  3. +2 −2 common/hugo/version_current.go
  4. +14 −0 common/maps/cache.go
  5. +26 −25 common/paths/pathparser.go
  6. +19 −0 common/paths/pathparser_test.go
  7. +3 −1 config/allconfig/allconfig.go
  8. +18 −0 config/allconfig/allconfig_integration_test.go
  9. +4 −0 config/allconfig/configlanguage.go
  10. +10 −0 config/configProvider.go
  11. +1 −3 create/content.go
  12. +1 −1 create/skeletons/theme/layouts/_default/baseof.html
  13. +30 −0 docs/data/docs.yaml
  14. +6 −5 go.mod
  15. +12 −10 go.sum
  16. +10 −13 helpers/content.go
  17. +1 −1 helpers/content_test.go
  18. +3 −3 helpers/general_test.go
  19. +7 −49 hugofs/files/classifier.go
  20. +0 −11 hugofs/files/classifier_test.go
  21. +8 −2 hugofs/walk.go
  22. +1 −1 hugolib/config_test.go
  23. +180 −17 hugolib/content_map.go
  24. +130 −54 hugolib/content_map_page.go
  25. +7 −7 hugolib/doctree/nodeshiftree_test.go
  26. +37 −18 hugolib/doctree/nodeshifttree.go
  27. +12 −5 hugolib/doctree/simpletree.go
  28. +3 −3 hugolib/doctree/support.go
  29. +35 −22 hugolib/doctree/treeshifttree.go
  30. +19 −0 hugolib/hugo_sites.go
  31. +109 −29 hugolib/hugo_sites_build.go
  32. +1 −1 hugolib/hugo_smoke_test.go
  33. +12 −2 hugolib/page.go
  34. +30 −15 hugolib/page__content.go
  35. +45 −31 hugolib/page__meta.go
  36. +33 −36 hugolib/page__new.go
  37. +9 −3 hugolib/page__per_output.go
  38. +39 −10 hugolib/pages_capture.go
  39. +331 −0 hugolib/pagesfromdata/pagesfromgotmpl.go
  40. +479 −0 hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go
  41. +32 −0 hugolib/pagesfromdata/pagesfromgotmpl_test.go
  42. +2 −2 hugolib/shortcode.go
  43. +27 −2 hugolib/site.go
  44. +23 −1 hugolib/site_new.go
  45. +2 −0 hugolib/site_sections.go
  46. +3 −2 hugoreleaser.env
  47. +1 −0 langs/i18n/translationProvider.go
  48. +34 −0 livereload/gen/livereload-hugo-plugin.js
  49. +61 −0 livereload/gen/main.go
  50. +5 −44 livereload/livereload.go
  51. +3,795 −1 livereload/livereload.js
  52. +7 −0 livereload/livereload.min.js
  53. +1 −2 magefile.go
  54. +10 −0 markup/goldmark/convert.go
  55. +41 −1 markup/goldmark/goldmark_config/config.go
  56. +50 −0 markup/goldmark/goldmark_integration_test.go
  57. +23 −6 markup/markup.go
  58. +18 −13 media/builtin.go
  59. +120 −2 media/config.go
  60. +12 −7 media/config_test.go
  61. +52 −3 media/mediaType.go
  62. +10 −2 media/mediaType_test.go
  63. +0 −1 parser/frontmatter.go
  64. +7 −0 resources/images/exif/exif.go
  65. +1 −1 resources/page/page_nop.go
  66. +306 −15 resources/page/pagemeta/page_frontmatter.go
  67. +31 −0 resources/page/pagemeta/page_frontmatter_test.go
  68. +2 −2 resources/page/pagemeta/pagemeta.go
  69. +2 −0 resources/postpub/fields_test.go
  70. +15 −1 resources/resource.go
  71. +10 −2 resources/resource/resourcetypes.go
  72. +28 −1 resources/resource_metadata.go
  73. +14 −2 resources/resource_spec.go
  74. +4 −4 resources/transform.go
  75. +8 −1 source/fileInfo.go
  76. +5 −1 tpl/template.go
  77. +6 −0 tpl/tplimpl/embedded/templates/_default/_markup/render-image.html
  78. +2 −2 tpl/tplimpl/embedded/templates/opengraph.html
  79. +2 −2 tpl/tplimpl/embedded/templates/schema.html
  80. +15 −9 tpl/tplimpl/embedded/templates/twitter_cards.html
  81. +11 −7 tpl/tplimpl/render_hook_integration_test.go
  82. +160 −1 tpl/tplimpl/tplimpl_integration_test.go
2 changes: 1 addition & 1 deletion commands/hugobuilder.go
Original file line number Diff line number Diff line change
@@ -854,7 +854,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
h.BaseFs.SourceFilesystems,
dynamicEvents)

onePageName := pickOneWriteOrCreatePath(partitionedEvents.ContentEvents)
onePageName := pickOneWriteOrCreatePath(h.Conf.ContentTypes(), partitionedEvents.ContentEvents)

c.printChangeDetected("")
c.changeDetector.PrepareNew()
8 changes: 4 additions & 4 deletions commands/server.go
Original file line number Diff line number Diff line change
@@ -46,12 +46,12 @@ import (
"github.com/fsnotify/fsnotify"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/hugo"

"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/common/urls"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/hugofs/files"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/hugolib/filesystems"
"github.com/gohugoio/hugo/livereload"
@@ -1188,16 +1188,16 @@ func partitionDynamicEvents(sourceFs *filesystems.SourceFilesystems, events []fs
return
}

func pickOneWriteOrCreatePath(events []fsnotify.Event) string {
func pickOneWriteOrCreatePath(contentTypes config.ContentTypesProvider, events []fsnotify.Event) string {
name := ""

for _, ev := range events {
if ev.Op&fsnotify.Write == fsnotify.Write || ev.Op&fsnotify.Create == fsnotify.Create {
if files.IsIndexContentFile(ev.Name) {
if contentTypes.IsIndexContentFile(ev.Name) {
return ev.Name
}

if files.IsContentFile(ev.Name) {
if contentTypes.IsContentFile(ev.Name) {
name = ev.Name
}

4 changes: 2 additions & 2 deletions common/hugo/version_current.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ package hugo
// This should be the only one.
var CurrentVersion = Version{
Major: 0,
Minor: 125,
PatchLevel: 7,
Minor: 126,
PatchLevel: 0,
Suffix: "",
}
14 changes: 14 additions & 0 deletions common/maps/cache.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,12 @@ func NewCache[K comparable, T any]() *Cache[K, T] {
}

// Delete deletes the given key from the cache.
// If c is nil, this method is a no-op.
func (c *Cache[K, T]) Get(key K) (T, bool) {
if c == nil {
var zero T
return zero, false
}
c.RLock()
v, found := c.m[key]
c.RUnlock()
@@ -60,6 +65,15 @@ func (c *Cache[K, T]) Set(key K, value T) {
c.Unlock()
}

// ForEeach calls the given function for each key/value pair in the cache.
func (c *Cache[K, T]) ForEeach(f func(K, T)) {
c.RLock()
defer c.RUnlock()
for k, v := range c.m {
f(k, v)
}
}

// SliceCache is a simple thread safe cache backed by a map.
type SliceCache[T any] struct {
m map[string][]T
51 changes: 26 additions & 25 deletions common/paths/pathparser.go
Original file line number Diff line number Diff line change
@@ -25,20 +25,16 @@ import (
"github.com/gohugoio/hugo/identity"
)

var defaultPathParser PathParser

// PathParser parses a path into a Path.
type PathParser struct {
// Maps the language code to its index in the languages/sites slice.
LanguageIndex map[string]int

// Reports whether the given language is disabled.
IsLangDisabled func(string) bool
}

// Parse parses component c with path s into Path using the default path parser.
func Parse(c, s string) *Path {
return defaultPathParser.Parse(c, s)
// Reports whether the given ext is a content file.
IsContentExt func(string) bool
}

// NormalizePathString returns a normalized path string using the very basic Hugo rules.
@@ -108,7 +104,6 @@ func (pp *PathParser) parse(component, s string) (*Path, error) {
var err error
// Preserve the original case for titles etc.
p.unnormalized, err = pp.doParse(component, s, pp.newPath(component))

if err != nil {
return nil, err
}
@@ -195,23 +190,26 @@ func (pp *PathParser) doParse(component, s string, p *Path) (*Path, error) {
}
}

isContentComponent := p.component == files.ComponentFolderContent || p.component == files.ComponentFolderArchetypes
isContent := isContentComponent && files.IsContentExt(p.Ext())

if isContent {
if len(p.identifiers) > 0 {
isContentComponent := p.component == files.ComponentFolderContent || p.component == files.ComponentFolderArchetypes
isContent := isContentComponent && pp.IsContentExt(p.Ext())
id := p.identifiers[len(p.identifiers)-1]
b := p.s[p.posContainerHigh : id.Low-1]
switch b {
case "index":
p.bundleType = PathTypeLeaf
case "_index":
p.bundleType = PathTypeBranch
default:
p.bundleType = PathTypeContentSingle
}
if isContent {
switch b {
case "index":
p.bundleType = PathTypeLeaf
case "_index":
p.bundleType = PathTypeBranch
default:
p.bundleType = PathTypeContentSingle
}

if slashCount == 2 && p.IsLeafBundle() {
p.posSectionHigh = 0
if slashCount == 2 && p.IsLeafBundle() {
p.posSectionHigh = 0
}
} else if b == files.NameContentData && files.IsContentDataExt(p.Ext()) {
p.bundleType = PathTypeContentData
}
}

@@ -246,6 +244,9 @@ const (

// Branch bundles, e.g. /blog/_index.md
PathTypeBranch

// Content data file, _content.gotmpl.
PathTypeContentData
)

type Path struct {
@@ -521,10 +522,6 @@ func (p *Path) Identifiers() []string {
return ids
}

func (p *Path) IsHTML() bool {
return files.IsHTML(p.Ext())
}

func (p *Path) BundleType() PathType {
return p.bundleType
}
@@ -541,6 +538,10 @@ func (p *Path) IsLeafBundle() bool {
return p.bundleType == PathTypeLeaf
}

func (p *Path) IsContentData() bool {
return p.bundleType == PathTypeContentData
}

func (p Path) ForBundleType(t PathType) *Path {
p.bundleType = t
return &p
19 changes: 19 additions & 0 deletions common/paths/pathparser_test.go
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ var testParser = &PathParser{
"no": 0,
"en": 1,
},
IsContentExt: func(ext string) bool {
return ext == "md"
},
}

func TestParse(t *testing.T) {
@@ -333,6 +336,22 @@ func TestParse(t *testing.T) {
c.Assert(p.Path(), qt.Equals, "/a/b/c.txt")
},
},
{
"Content data file gotmpl",
"/a/b/_content.gotmpl",
func(c *qt.C, p *Path) {
c.Assert(p.Path(), qt.Equals, "/a/b/_content.gotmpl")
c.Assert(p.Ext(), qt.Equals, "gotmpl")
c.Assert(p.IsContentData(), qt.IsTrue)
},
},
{
"Content data file yaml",
"/a/b/_content.yaml",
func(c *qt.C, p *Path) {
c.Assert(p.IsContentData(), qt.IsFalse)
},
},
}
for _, test := range tests {
c.Run(test.name, func(c *qt.C) {
4 changes: 3 additions & 1 deletion config/allconfig/allconfig.go
Original file line number Diff line number Diff line change
@@ -367,6 +367,7 @@ func (c *Config) CompileConfig(logger loggers.Logger) error {
DisabledLanguages: disabledLangs,
IgnoredLogs: ignoredLogIDs,
KindOutputFormats: kindOutputFormats,
ContentTypes: media.DefaultContentTypes.FromTypes(c.MediaTypes.Config),
CreateTitle: helpers.GetTitleFunc(c.TitleCaseStyle),
IsUglyURLSection: isUglyURL,
IgnoreFile: ignoreFile,
@@ -402,6 +403,7 @@ type ConfigCompiled struct {
BaseURLLiveReload urls.BaseURL
ServerInterface string
KindOutputFormats map[string]output.Formats
ContentTypes media.ContentTypes
DisabledKinds map[string]bool
DisabledLanguages map[string]bool
IgnoredLogs map[string]bool
@@ -759,7 +761,7 @@ func (c *Configs) Init() error {
c.Languages = languages
c.LanguagesDefaultFirst = languagesDefaultFirst

c.ContentPathParser = &paths.PathParser{LanguageIndex: languagesDefaultFirst.AsIndexSet(), IsLangDisabled: c.Base.IsLangDisabled}
c.ContentPathParser = &paths.PathParser{LanguageIndex: languagesDefaultFirst.AsIndexSet(), IsLangDisabled: c.Base.IsLangDisabled, IsContentExt: c.Base.C.ContentTypes.IsContentSuffix}

c.configLangs = make([]config.AllProvider, len(c.Languages))
for i, l := range c.LanguagesDefaultFirst {
18 changes: 18 additions & 0 deletions config/allconfig/allconfig_integration_test.go
Original file line number Diff line number Diff line change
@@ -84,3 +84,21 @@ logPathWarnings = true
b.Assert(conf.PrintI18nWarnings, qt.Equals, true)
b.Assert(conf.PrintPathWarnings, qt.Equals, true)
}

func TestRedefineContentTypes(t *testing.T) {
files := `
-- hugo.toml --
baseURL = "https://example.com"
[mediaTypes]
[mediaTypes."text/html"]
suffixes = ["html", "xhtml"]
`

b := hugolib.Test(t, files)

conf := b.H.Configs.Base
contentTypes := conf.C.ContentTypes

b.Assert(contentTypes.HTML.Suffixes(), qt.DeepEquals, []string{"html", "xhtml"})
b.Assert(contentTypes.Markdown.Suffixes(), qt.DeepEquals, []string{"md", "mdown", "markdown"})
}
4 changes: 4 additions & 0 deletions config/allconfig/configlanguage.go
Original file line number Diff line number Diff line change
@@ -144,6 +144,10 @@ func (c ConfigLanguage) NewIdentityManager(name string) identity.Manager {
return identity.NewManager(name)
}

func (c ConfigLanguage) ContentTypes() config.ContentTypesProvider {
return c.config.C.ContentTypes
}

// GetConfigSection is mostly used in tests. The switch statement isn't complete, but what's in use.
func (c ConfigLanguage) GetConfigSection(s string) any {
switch s {
10 changes: 10 additions & 0 deletions config/configProvider.go
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ type AllProvider interface {
Dirs() CommonDirs
Quiet() bool
DirsBase() CommonDirs
ContentTypes() ContentTypesProvider
GetConfigSection(string) any
GetConfig() any
CanonifyURLs() bool
@@ -75,6 +76,15 @@ type AllProvider interface {
EnableEmoji() bool
}

// We cannot import the media package as that would create a circular dependency.
// This interface defineds a sub set of what media.ContentTypes provides.
type ContentTypesProvider interface {
IsContentSuffix(suffix string) bool
IsContentFile(filename string) bool
IsIndexContentFile(filename string) bool
IsHTMLSuffix(suffix string) bool
}

// Provider provides the configuration settings for Hugo.
type Provider interface {
GetString(key string) string
4 changes: 1 addition & 3 deletions create/content.go
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@ import (
"github.com/gohugoio/hugo/common/hstrings"
"github.com/gohugoio/hugo/common/paths"

"github.com/gohugoio/hugo/hugofs/files"

"github.com/gohugoio/hugo/hugofs"

"github.com/gohugoio/hugo/helpers"
@@ -98,7 +96,7 @@ func NewContent(h *hugolib.HugoSites, kind, targetPath string, force bool) error
return "", fmt.Errorf("failed to resolve %q to an archetype template", targetPath)
}

if !files.IsContentFile(b.targetPath) {
if !h.Conf.ContentTypes().IsContentFile(b.targetPath) {
return "", fmt.Errorf("target path %q is not a known content format", b.targetPath)
}

2 changes: 1 addition & 1 deletion create/skeletons/theme/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ or site.Language.LanguageCode site.Language.Lang }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
<html lang="{{ or site.Language.LanguageCode }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
<head>
{{ partial "head.html" . }}
</head>
30 changes: 30 additions & 0 deletions docs/data/docs.yaml
Original file line number Diff line number Diff line change
@@ -1065,6 +1065,15 @@ config:
enable: false
escapedSpace: false
definitionList: true
extras:
insert:
enable: false
mark:
enable: false
subscript:
enable: false
superscript:
enable: false
footnote: true
linkify: true
linkifyProtocol: https
@@ -1200,6 +1209,12 @@ config:
delimiter: .
suffixes:
- webp
text/asciidoc:
delimiter: .
suffixes:
- adoc
- asciidoc
- ad
text/calendar:
delimiter: .
suffixes:
@@ -1216,6 +1231,7 @@ config:
delimiter: .
suffixes:
- html
- htm
text/javascript:
delimiter: .
suffixes:
@@ -1230,11 +1246,25 @@ config:
delimiter: .
suffixes:
- md
- mdown
- markdown
text/org:
delimiter: .
suffixes:
- org
text/pandoc:
delimiter: .
suffixes:
- pandoc
- pdc
text/plain:
delimiter: .
suffixes:
- txt
text/rst:
delimiter: .
suffixes:
- rst
text/tsx:
delimiter: .
suffixes:
Loading