Repository: gohugoio/hugo (language: go)

Issue:
Add hugo.IsServer as alias of site.IsServer
I was changing some code from `hugo.IsProduction` and I tried writing `hugo.IsServer`, which it turns out does not work. This is should be `site.IsServer` instead. But why? I think the answer is that `site.IsServer` predates the `hugo` action. Now that we have `hugo`, I think `site.IsServer` should be removed from the docs (although maybe not actually removed for a long time) and `hugo.IsServer` should be added.


Discussion / hints:
I agree that's  a better place for it, but also want to clarify that hugo.IsProduction and site.IsServer are two very different things:

```
$ hugo server -e production

{{ site.IsServer }} --> true
{{ site.IsProduction }} --> true
```

And I think `hugo.Environment` is the most useful of the three.
Yeah, I was changing the code because it was testing for prod but it really needed to be testing for server vs compiled. 

Fix patch:
diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go
index c28dd0b5308..1138cf2acb6 100644
--- a/common/hugo/hugo.go
+++ b/common/hugo/hugo.go
@@ -78,10 +78,22 @@ func (i HugoInfo) Generator() template.HTML {
 	return template.HTML(fmt.Sprintf(`<meta name="generator" content="Hugo %s">`, CurrentVersion.String()))
 }
 
+// IsDevelopment reports whether the current running environment is "development".
+func (i HugoInfo) IsDevelopment() bool {
+	return i.Environment == EnvironmentDevelopment
+}
+
+// IsProduction reports whether the current running environment is "production".
 func (i HugoInfo) IsProduction() bool {
 	return i.Environment == EnvironmentProduction
 }
 
+// IsServer reports whether the built-in server is running.
+func (i HugoInfo) IsServer() bool {
+	return i.conf.Running()
+}
+
+// IsExtended reports whether the Hugo binary is the extended version.
 func (i HugoInfo) IsExtended() bool {
 	return IsExtended
 }
@@ -99,6 +111,7 @@ func (i HugoInfo) Deps() []*Dependency {
 // ConfigProvider represents the config options that are relevant for HugoInfo.
 type ConfigProvider interface {
 	Environment() string
+	Running() bool
 	WorkingDir() string
 }
 
diff --git a/docs/content/en/functions/hugo.md b/docs/content/en/functions/hugo.md
index 78d658c6665..5ed1ae85c93 100644
--- a/docs/content/en/functions/hugo.md
+++ b/docs/content/en/functions/hugo.md
@@ -31,11 +31,17 @@ relatedfuncs: []
 `hugo.GoVersion`
 : (`string`) The Go version used to compile the Hugo binary (e.g., `go1.20.4`). {{< new-in "0.101.0" >}}
 
+`hugo.IsDevelopment`
+: (`bool`) Returns `true` if `hugo.Environment` is "development".
+
 `hugo.IsExtended`
 : (`bool`) Returns `true` if the Hugo binary is the extended version.
 
 `hugo.IsProduction`
-: (`bool`) Returns `true` if `hugo.Environment` is set to the production environment.
+: (`bool`) Returns `true` if `hugo.Environment` is "production".
+
+`hugo.IsServer`
+: (`bool`) Returns `true` if the site is being served with Hugo's built-in server.
 
 `hugo.Version`
 : (`hugo.VersionString`) The current version of the Hugo binary (e.g., `0.112.1`).
diff --git a/docs/content/en/variables/site.md b/docs/content/en/variables/site.md
index 117f4534603..ced5617b430 100644
--- a/docs/content/en/variables/site.md
+++ b/docs/content/en/variables/site.md
@@ -47,9 +47,6 @@ All the methods below, e.g. `.Site.RegularPages` can also be reached via the glo
 .Site.IsMultiLingual
 : whether there are more than one language in this site. See [Multilingual](/content-management/multilingual/) for more information.
 
-.Site.IsServer
-: a boolean to indicate if the site is being served with Hugo's built-in server. See [`hugo server`](/commands/hugo_server/) for more information.
-
 .Site.Language.Lang
 : the language code of the current locale (e.g., `en`).
 
diff --git a/hugolib/site_new.go b/hugolib/site_new.go
index 8abd511c3ec..4db5eeb2871 100644
--- a/hugolib/site_new.go
+++ b/hugolib/site_new.go
@@ -356,7 +356,9 @@ func newHugoSitesNew(cfg deps.DepsCfg, d *deps.Deps, sites []*Site) (*HugoSites,
 }
 
 // Returns true if we're running in a server.
+// Deprecated: use hugo.IsServer instead
 func (s *Site) IsServer() bool {
+	helpers.Deprecated(".Site.IsServer", "Use hugo.IsServer instead.", false)
 	return s.conf.Internal.Running
 }
 
diff --git a/resources/page/site.go b/resources/page/site.go
index 6a352ef866c..7b8960fdd3d 100644
--- a/resources/page/site.go
+++ b/resources/page/site.go
@@ -56,6 +56,7 @@ type Site interface {
 	Home() Page
 
 	// Returns true if we're running in a server.
+	// Deprecated: use hugo.IsServer instead
 	IsServer() bool
 
 	// Returns the server port.
@@ -211,6 +212,7 @@ func (s *siteWrapper) Home() Page {
 	return s.s.Home()
 }
 
+// Deprecated: use hugo.IsServer instead
 func (s *siteWrapper) IsServer() bool {
 	return s.s.IsServer()
 }
@@ -383,6 +385,7 @@ func (t testSite) GetIdentity() identity.Identity {
 	return identity.KeyValueIdentity{Key: "site", Value: t.l.Lang}
 }
 
+// Deprecated: use hugo.IsServer instead
 func (t testSite) IsServer() bool {
 	return false
 }


Test patch:
diff --git a/common/hugo/hugo_test.go b/common/hugo/hugo_test.go
index b0279f11137..5b4a6f9ad20 100644
--- a/common/hugo/hugo_test.go
+++ b/common/hugo/hugo_test.go
@@ -23,7 +23,7 @@ import (
 func TestHugoInfo(t *testing.T) {
 	c := qt.New(t)
 
-	conf := testConfig{environment: "production", workingDir: "/mywork"}
+	conf := testConfig{environment: "production", workingDir: "/mywork", running: false}
 	hugoInfo := NewInfo(conf, nil)
 
 	c.Assert(hugoInfo.Version(), qt.Equals, CurrentVersion.Version())
@@ -38,15 +38,20 @@ func TestHugoInfo(t *testing.T) {
 	}
 	c.Assert(hugoInfo.Environment, qt.Equals, "production")
 	c.Assert(string(hugoInfo.Generator()), qt.Contains, fmt.Sprintf("Hugo %s", hugoInfo.Version()))
+	c.Assert(hugoInfo.IsDevelopment(), qt.Equals, false)
 	c.Assert(hugoInfo.IsProduction(), qt.Equals, true)
 	c.Assert(hugoInfo.IsExtended(), qt.Equals, IsExtended)
+	c.Assert(hugoInfo.IsServer(), qt.Equals, false)
 
-	devHugoInfo := NewInfo(testConfig{environment: "development"}, nil)
+	devHugoInfo := NewInfo(testConfig{environment: "development", running: true}, nil)
+	c.Assert(devHugoInfo.IsDevelopment(), qt.Equals, true)
 	c.Assert(devHugoInfo.IsProduction(), qt.Equals, false)
+	c.Assert(devHugoInfo.IsServer(), qt.Equals, true)
 }
 
 type testConfig struct {
 	environment string
+	running     bool
 	workingDir  string
 }
 
@@ -54,6 +59,10 @@ func (c testConfig) Environment() string {
 	return c.environment
 }
 
+func (c testConfig) Running() bool {
+	return c.running
+}
+
 func (c testConfig) WorkingDir() string {
 	return c.workingDir
 }
diff --git a/resources/page/page_matcher_test.go b/resources/page/page_matcher_test.go
index da47843db98..2108d51c290 100644
--- a/resources/page/page_matcher_test.go
+++ b/resources/page/page_matcher_test.go
@@ -159,6 +159,7 @@ func TestDecodeCascadeConfig(t *testing.T) {
 
 type testConfig struct {
 	environment string
+	running     bool
 	workingDir  string
 }
 
@@ -166,6 +167,10 @@ func (c testConfig) Environment() string {
 	return c.environment
 }
 
+func (c testConfig) Running() bool {
+	return c.running
+}
+
 func (c testConfig) WorkingDir() string {
 	return c.workingDir
 }