Repository: gohugoio/hugo (language: go)

Issue:
Deprecate or remove path in front matter
We added it in `v0.123.0` and it's not documented, so it should not be in widespread use.

So, it works, but the main problem with it, which I'm not prepared to spend time fixing, is the partial rebuild on content change logic. 

This was added to prepare for "data from pages", which was a good idea, but for content filed (e.g. `mypage.md`), it's not.


Discussion / hints:
I'd say remove it without deprecation. The `kind` and `lang` front matter values not documented either, so if you need to...
I just spent a little too much time tracking this down:
<https://discourse.gohugo.io/t/get-a-page-resource-by-name/53483/9>

It's a uncommon problem (I think this is only the third time that I've encountered it), but I still like the idea of deprecating or removing `kind`, `lang`, and `path` from front matter. None are documented, other than using them with the `AddPage` method within a content adapter.




Fix patch:
diff --git a/commands/commandeer.go b/commands/commandeer.go
index c53235cefe5..697ece1f054 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -448,7 +448,7 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
 		return err
 	}
 	// Set up the global logger early to allow info deprecations during config load.
-	loggers.InitGlobalLogger(r.logger.Level(), false)
+	loggers.SetGlobalLogger(r.logger)
 
 	r.changesFromBuild = make(chan []identity.Identity, 10)
 
diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go
index 8b32432db0f..815c25fa750 100644
--- a/common/hugo/hugo.go
+++ b/common/hugo/hugo.go
@@ -414,6 +414,15 @@ func Deprecate(item, alternative string, version string) {
 	DeprecateLevel(item, alternative, version, level)
 }
 
+// DeprecateLevelMin informs about a deprecation starting at the given version, but with a minimum log level.
+func DeprecateLevelMin(item, alternative string, version string, minLevel logg.Level) {
+	level := deprecationLogLevelFromVersion(version)
+	if level < minLevel {
+		level = minLevel
+	}
+	DeprecateLevel(item, alternative, version, level)
+}
+
 // DeprecateLevel informs about a deprecation logging at the given level.
 func DeprecateLevel(item, alternative, version string, level logg.Level) {
 	var msg string
diff --git a/common/loggers/loggerglobal.go b/common/loggers/loggerglobal.go
index c3e2970d053..b8c9a6931d6 100644
--- a/common/loggers/loggerglobal.go
+++ b/common/loggers/loggerglobal.go
@@ -21,7 +21,15 @@ import (
 	"github.com/bep/logg"
 )
 
-func InitGlobalLogger(level logg.Level, panicOnWarnings bool) {
+// SetGlobalLogger sets the global logger.
+// This is used in a few places in Hugo, e.g. deprecated functions.
+func SetGlobalLogger(logger Logger) {
+	logMu.Lock()
+	defer logMu.Unlock()
+	log = logger
+}
+
+func initGlobalLogger(level logg.Level, panicOnWarnings bool) {
 	logMu.Lock()
 	defer logMu.Unlock()
 	var logHookLast func(e *logg.Entry) error
@@ -50,5 +58,5 @@ func Log() Logger {
 var log Logger
 
 func init() {
-	InitGlobalLogger(logg.LevelWarn, false)
+	initGlobalLogger(logg.LevelWarn, false)
 }
diff --git a/config/allconfig/load.go b/config/allconfig/load.go
index 999e03645b0..9e9c7a42a56 100644
--- a/config/allconfig/load.go
+++ b/config/allconfig/load.go
@@ -91,7 +91,7 @@ func LoadConfig(d ConfigSourceDescriptor) (*Configs, error) {
 		return nil, fmt.Errorf("failed to init config: %w", err)
 	}
 
-	loggers.InitGlobalLogger(d.Logger.Level(), configs.Base.PanicOnWarning)
+	loggers.SetGlobalLogger(d.Logger)
 
 	return configs, nil
 }
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go
index 38fe6db56db..20ce1aa597b 100644
--- a/hugolib/page__meta.go
+++ b/hugolib/page__meta.go
@@ -21,6 +21,7 @@ import (
 	"strings"
 	"time"
 
+	"github.com/bep/logg"
 	"github.com/gobuffalo/flect"
 	"github.com/gohugoio/hugo/langs"
 	"github.com/gohugoio/hugo/markup/converter"
@@ -32,6 +33,7 @@ import (
 
 	"github.com/gohugoio/hugo/common/constants"
 	"github.com/gohugoio/hugo/common/hashing"
+	"github.com/gohugoio/hugo/common/hugo"
 	"github.com/gohugoio/hugo/common/loggers"
 	"github.com/gohugoio/hugo/common/maps"
 	"github.com/gohugoio/hugo/common/paths"
@@ -486,6 +488,11 @@ params:
 			continue
 		}
 
+		if loki == "path" || loki == "kind" || loki == "lang" {
+			// See issue 12484.
+			hugo.DeprecateLevelMin(loki+" in front matter", "", "v0.144.0", logg.LevelWarn)
+		}
+
 		switch loki {
 		case "title":
 			pcfg.Title = cast.ToString(v)


Test patch:
diff --git a/config/privacy/privacyConfig_test.go b/config/privacy/privacyConfig_test.go
index 6cde91165ef..1dd20215bc4 100644
--- a/config/privacy/privacyConfig_test.go
+++ b/config/privacy/privacyConfig_test.go
@@ -36,10 +36,6 @@ respectDoNotTrack = true
 [privacy.instagram]
 disable = true
 simple = true
-[privacy.twitter]
-disable = true
-enableDNT = true
-simple = true
 [privacy.x]
 disable = true
 enableDNT = true
@@ -63,8 +59,8 @@ simple = true
 	got := []bool{
 		pc.Disqus.Disable, pc.GoogleAnalytics.Disable,
 		pc.GoogleAnalytics.RespectDoNotTrack, pc.Instagram.Disable,
-		pc.Instagram.Simple, pc.Twitter.Disable, pc.Twitter.EnableDNT,
-		pc.Twitter.Simple, pc.Vimeo.Disable, pc.Vimeo.EnableDNT, pc.Vimeo.Simple,
+		pc.Instagram.Simple,
+		pc.Vimeo.Disable, pc.Vimeo.EnableDNT, pc.Vimeo.Simple,
 		pc.YouTube.PrivacyEnhanced, pc.YouTube.Disable, pc.X.Disable, pc.X.EnableDNT,
 		pc.X.Simple,
 	}
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index 39a16d948bf..0fec397e0d8 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1942,3 +1942,29 @@ Hugo: h-Home|
 `,
 	)
 }
+
+// See #12484
+func TestPageFrontMatterDeprecatePathKindLang(t *testing.T) {
+	// This cannot be parallel as it depends on output from the global logger.
+
+	files := `
+-- hugo.toml --
+disableKinds = ["taxonomy", "term", "home", "section"]
+-- content/p1.md --
+---
+title: "p1"
+kind: "page"
+lang: "en"
+path: "mypath"
+---
+-- layouts/_default/single.html --
+Title: {{ .Title }}
+`
+	b := Test(t, files, TestOptWarn())
+	b.AssertFileContent("public/mypath/index.html", "p1")
+	b.AssertLogContains(
+		"deprecated: kind in front matter was deprecated",
+		"deprecated: lang in front matter was deprecated",
+		"deprecated: path in front matter was deprecated",
+	)
+}
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
index 9fdb6323848..2007b658dd0 100644
--- a/hugolib/testhelpers_test.go
+++ b/hugolib/testhelpers_test.go
@@ -260,8 +260,6 @@ disable = false
 respectDoNotTrack = true
 [privacy.instagram]
 simple = true
-[privacy.twitter]
-enableDNT = true
 [privacy.x]
 enableDNT = true
 [privacy.vimeo]
diff --git a/tpl/tplimpl/shortcodes_integration_test.go b/tpl/tplimpl/shortcodes_integration_test.go
index 0578e2d8b56..b8a4ad83308 100644
--- a/tpl/tplimpl/shortcodes_integration_test.go
+++ b/tpl/tplimpl/shortcodes_integration_test.go
@@ -22,7 +22,7 @@ import (
 )
 
 func TestCommentShortcode(t *testing.T) {
-	t.Parallel()
+	// This cannot be parallel as it depends on output from the global logger.
 
 	files := `
 -- hugo.toml --