Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,450 changes: 1,448 additions & 2 deletions commands/gen.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions config/allconfig/allconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ type RootConfig struct {

// When using ref or relref to resolve page links and a link cannot be resolved, it will be logged with this log level.
// Valid values are ERROR (default) or WARNING. Any ERROR will fail the build (exit -1).
RefLinksErrorLevel string
RefLinksErrorLevel string `jsonschema:"enum=ERROR,enum=WARNING"`

// This will create a menu with all the sections as menu items and all the sections’ pages as “shadow-members”.
SectionPagesMenu string
Expand All @@ -692,7 +692,7 @@ type RootConfig struct {

// Set titleCaseStyle to specify the title style used by the title template function and the automatic section titles in Hugo.
// It defaults to AP Stylebook for title casing, but you can also set it to Chicago or Go (every word starts with a capital letter).
TitleCaseStyle string
TitleCaseStyle string `jsonschema:"enum=ap,enum=chicago,enum=go,enum=firstupper,enum=none"`

// The editor used for opening up new content.
NewContentEditor string
Expand Down
8 changes: 4 additions & 4 deletions config/commonConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var defaultBuild = BuildConfig{
type BuildConfig struct {
// When to use the resource file cache.
// One of never, fallback, always. Default is fallback
UseResourceCacheWhen string
UseResourceCacheWhen string `jsonschema:"enum=never,enum=fallback,enum=always"`

// When enabled, will collect and write a hugo_stats.json with some build
// related aggregated data (e.g. CSS class names).
Expand Down Expand Up @@ -208,7 +208,7 @@ func DecodeBuildConfig(cfg Provider) BuildConfig {
// SitemapConfig configures the sitemap to be generated.
type SitemapConfig struct {
// The page change frequency.
ChangeFreq string
ChangeFreq string `jsonschema:"enum=always,enum=hourly,enum=daily,enum=weekly,enum=monthly,enum=yearly,enum=never"`
// The priority of the page.
Priority float64
// The sitemap filename.
Expand Down Expand Up @@ -498,10 +498,10 @@ type Pagination struct {
// PageConfig configures the behavior of pages.
type PageConfig struct {
// Sort order for Page.Next and Page.Prev. Default "desc" (the default page sort order in Hugo).
NextPrevSortOrder string
NextPrevSortOrder string `jsonschema:"enum=asc,enum=desc"`

// Sort order for Page.NextInSection and Page.PrevInSection. Default "desc".
NextPrevInSectionSortOrder string
NextPrevInSectionSortOrder string `jsonschema:"enum=asc,enum=desc"`
}

func (c *PageConfig) CompileConfig(loggers.Logger) error {
Expand Down
1 change: 1 addition & 0 deletions docs/content/en/commands/hugo_gen.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ Generate documentation for your project using Hugo's documentation engine, inclu
* [hugo](/commands/hugo/) - Build your site
* [hugo gen chromastyles](/commands/hugo_gen_chromastyles/) - Generate CSS stylesheet for the Chroma code highlighter
* [hugo gen doc](/commands/hugo_gen_doc/) - Generate Markdown documentation for the Hugo CLI
* [hugo gen jsonschemas](/commands/hugo_gen_jsonschemas/) - Generate JSON Schema for Hugo config and page structures
* [hugo gen man](/commands/hugo_gen_man/) - Generate man pages for the Hugo CLI

45 changes: 45 additions & 0 deletions docs/content/en/commands/hugo_gen_jsonschemas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "hugo gen jsonschemas"
slug: hugo_gen_jsonschemas
url: /commands/hugo_gen_jsonschemas/
---
## hugo gen jsonschemas

Generate JSON Schema for Hugo config and page structures

### Synopsis

Generate a JSON Schema for Hugo configuration options and page structures using reflection.

```
hugo gen jsonschemas [flags] [args]
```

### Options

```
--dir string output directory for schema files (default "/tmp/hugo-schemas")
-h, --help help for jsonschemas
```

### Options inherited from parent commands

```
--clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
--config string config file (default is hugo.yaml|json|toml)
--configDir string config dir (default "config")
-d, --destination string filesystem path to write files to
-e, --environment string build environment
--ignoreVendorPaths string ignores any _vendor for module paths matching the given Glob pattern
--logLevel string log level (debug|info|warn|error)
--noBuildLock don't create .hugo_build.lock file
--quiet build in quiet mode
-M, --renderToMemory render to memory (mostly useful when running the server)
-s, --source string filesystem path to read files relative from
--themesDir string filesystem path to themes directory
```

### SEE ALSO

* [hugo gen](/commands/hugo_gen/) - Generate documentation and syntax highlighting styles

67 changes: 67 additions & 0 deletions docs/content/en/jsonschemas/hugo-config-build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://gohugo.io/jsonschemas/hugo-config-build.schema.json",
"properties": {
"useResourceCacheWhen": {
"oneOf": [
{
"const": "never"
},
{
"const": "fallback"
},
{
"const": "always"
}
],
"type": "string",
"description": "When to use the resource file cache.\nOne of never, fallback, always. Default is fallback \nhttps://gohugo.io/configuration/build/#useresourcecachewhen"
},
"buildStats": {
"properties": {
"enable": {
"type": "boolean",
"description": "https://gohugo.io/configuration/build/#enable"
},
"disableTags": {
"type": "boolean",
"description": "https://gohugo.io/configuration/build/#disabletags"
},
"disableClasses": {
"type": "boolean",
"description": "https://gohugo.io/configuration/build/#disableclasses"
},
"disableIDs": {
"type": "boolean",
"description": "https://gohugo.io/configuration/build/#disableids"
}
},
"type": "object",
"description": "When enabled, will collect and write a hugo_stats.json with some build\nrelated aggregated data (e.g. CSS class names).\nNote that this was a bool \u003c= v0.115.0. \nhttps://gohugo.io/configuration/build/#buildstats"
},
"noJSConfigInAssets": {
"type": "boolean",
"description": "Can be used to toggle off writing of the IntelliSense /assets/jsconfig.js\nfile. \nhttps://gohugo.io/configuration/build/#nojsconfiginassets"
},
"cacheBusters": {
"items": {
"properties": {
"source": {
"type": "string",
"description": "Trigger for files matching this regexp. \nhttps://gohugo.io/configuration/build/#source"
},
"target": {
"type": "string",
"description": "Cache bust targets matching this regexp.\nThis regexp can contain group matches (e.g. $1) from the source regexp. \nhttps://gohugo.io/configuration/build/#target"
}
},
"type": "object",
"description": "CacheBuster configures cache busting for assets."
},
"type": "array",
"description": "Can used to control how the resource cache gets evicted on rebuilds. \nhttps://gohugo.io/configuration/build/#cachebusters"
}
},
"type": "object",
"description": "BuildConfig holds some build related configuration."
}
37 changes: 37 additions & 0 deletions docs/content/en/jsonschemas/hugo-config-cascade.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://gohugo.io/jsonschemas/hugo-config-cascade.schema.json",
"properties": {
"params": {
"type": "object",
"description": "Apply Params to all Pages matching Target. \nhttps://gohugo.io/configuration/cascade/#params"
},
"fields": {
"type": "object",
"description": "Fields holds all fields but Params. \nhttps://gohugo.io/configuration/cascade/#fields"
},
"target": {
"properties": {
"path": {
"type": "string",
"description": "A Glob pattern matching the content path below /content.\nExpects Unix-styled slashes.\nNote that this is the virtual path, so it starts at the mount root\nwith a leading \"/\". \nhttps://gohugo.io/configuration/cascade/#path"
},
"kind": {
"type": "string",
"description": "A Glob pattern matching the Page's Kind(s), e.g. \"{home,section}\" \nhttps://gohugo.io/configuration/cascade/#kind"
},
"lang": {
"type": "string",
"description": "A Glob pattern matching the Page's language, e.g. \"{en,sv}\". \nhttps://gohugo.io/configuration/cascade/#lang"
},
"environment": {
"type": "string",
"description": "A Glob pattern matching the Page's Environment, e.g. \"{production,development}\". \nhttps://gohugo.io/configuration/cascade/#environment"
}
},
"type": "object",
"description": "Target is the PageMatcher that this config applies to. \nhttps://gohugo.io/configuration/cascade/#target"
}
},
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://gohugo.io/jsonschemas/hugo-config-contenttypes.schema.json",
"properties": {},
"type": "object"
}
114 changes: 114 additions & 0 deletions docs/content/en/jsonschemas/hugo-config-deployment.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://gohugo.io/jsonschemas/hugo-config-deployment.schema.json",
"properties": {
"targets": {
"items": {
"properties": {
"name": {
"type": "string",
"description": "https://gohugo.io/configuration/deployment/#name"
},
"uRL": {
"type": "string",
"description": "https://gohugo.io/configuration/deployment/#url"
},
"cloudFrontDistributionID": {
"type": "string",
"description": "https://gohugo.io/configuration/deployment/#cloudfrontdistributionid"
},
"googleCloudCDNOrigin": {
"type": "string",
"description": "GoogleCloudCDNOrigin specifies the Google Cloud project and CDN origin to\ninvalidate when deploying this target. It is specified as \u003cproject\u003e/\u003corigin\u003e. \nhttps://gohugo.io/configuration/deployment/#googlecloudcdnorigin"
},
"include": {
"type": "string",
"description": "Optional patterns of files to include/exclude for this target.\nParsed using github.com/gobwas/glob. \nhttps://gohugo.io/configuration/deployment/#include"
},
"exclude": {
"type": "string",
"description": "https://gohugo.io/configuration/deployment/#exclude"
},
"stripIndexHTML": {
"type": "boolean",
"description": "If true, any local path matching \u003cdir\u003e/index.html will be mapped to the\nremote path \u003cdir\u003e/. This does not affect the top-level index.html file,\nsince that would result in an empty path. \nhttps://gohugo.io/configuration/deployment/#stripindexhtml"
}
},
"type": "object"
},
"type": "array",
"description": "https://gohugo.io/configuration/deployment/#targets"
},
"matchers": {
"items": {
"properties": {
"pattern": {
"type": "string",
"description": "Pattern is the string pattern to match against paths.\nMatching is done against paths converted to use / as the path separator. \nhttps://gohugo.io/configuration/deployment/#pattern"
},
"cacheControl": {
"type": "string",
"description": "CacheControl specifies caching attributes to use when serving the blob.\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control \nhttps://gohugo.io/configuration/deployment/#cachecontrol"
},
"contentEncoding": {
"type": "string",
"description": "ContentEncoding specifies the encoding used for the blob's content, if any.\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding \nhttps://gohugo.io/configuration/deployment/#contentencoding"
},
"contentType": {
"type": "string",
"description": "ContentType specifies the MIME type of the blob being written.\nhttps://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type \nhttps://gohugo.io/configuration/deployment/#contenttype"
},
"gzip": {
"type": "boolean",
"description": "Gzip determines whether the file should be gzipped before upload.\nIf so, the ContentEncoding field will automatically be set to \"gzip\". \nhttps://gohugo.io/configuration/deployment/#gzip"
},
"force": {
"type": "boolean",
"description": "Force indicates that matching files should be re-uploaded. Useful when\nother route-determined metadata (e.g., ContentType) has changed. \nhttps://gohugo.io/configuration/deployment/#force-1"
}
},
"type": "object",
"description": "Matcher represents configuration to be applied to files whose paths match a specified pattern."
},
"type": "array",
"description": "https://gohugo.io/configuration/deployment/#matchers"
},
"order": {
"items": {
"type": "string"
},
"type": "array",
"description": "https://gohugo.io/configuration/deployment/#order"
},
"target": {
"type": "string",
"description": "Usually set via flags.\nTarget deployment Name; defaults to the first one. \nhttps://gohugo.io/configuration/deployment/#target"
},
"confirm": {
"type": "boolean",
"description": "Show a confirm prompt before deploying. \nhttps://gohugo.io/configuration/deployment/#confirm"
},
"dryRun": {
"type": "boolean",
"description": "DryRun will try the deployment without any remote changes. \nhttps://gohugo.io/configuration/deployment/#dryrun"
},
"force": {
"type": "boolean",
"description": "Force will re-upload all files. \nhttps://gohugo.io/configuration/deployment/#force-1"
},
"invalidateCDN": {
"type": "boolean",
"description": "Invalidate the CDN cache listed in the deployment target. \nhttps://gohugo.io/configuration/deployment/#invalidatecdn"
},
"maxDeletes": {
"type": "integer",
"description": "MaxDeletes is the maximum number of files to delete. \nhttps://gohugo.io/configuration/deployment/#maxdeletes"
},
"workers": {
"type": "integer",
"description": "Number of concurrent workers to use when uploading files. \nhttps://gohugo.io/configuration/deployment/#workers"
}
},
"type": "object",
"description": "DeployConfig is the complete configuration for deployment."
}
35 changes: 35 additions & 0 deletions docs/content/en/jsonschemas/hugo-config-frontmatter.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft-07/schema",
"$id": "https://gohugo.io/jsonschemas/hugo-config-frontmatter.schema.json",
"properties": {
"date": {
"items": {
"type": "string"
},
"type": "array",
"description": "Controls how the Date is set from front matter. \nhttps://gohugo.io/configuration/front-matter/#dates"
},
"lastmod": {
"items": {
"type": "string"
},
"type": "array",
"description": "Controls how the Lastmod is set from front matter. \nhttps://gohugo.io/configuration/front-matter/#dates"
},
"publishDate": {
"items": {
"type": "string"
},
"type": "array",
"description": "Controls how the PublishDate is set from front matter. \nhttps://gohugo.io/configuration/front-matter/#dates"
},
"expiryDate": {
"items": {
"type": "string"
},
"type": "array",
"description": "Controls how the ExpiryDate is set from front matter. \nhttps://gohugo.io/configuration/front-matter/#dates"
}
},
"type": "object"
}
Loading
Loading