mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Merge commit 'e5568488051a571df48401e03f1304b95dbc9028'
This commit is contained in:
commit
5e39eb20a6
16 changed files with 58 additions and 23 deletions
|
@ -135,10 +135,6 @@ A leaf bundle can be made headless by adding below in the Front Matter
|
||||||
headless = true
|
headless = true
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% note %}}
|
|
||||||
Only leaf bundles can be made headless.
|
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
There are many use cases of such headless page bundles:
|
There are many use cases of such headless page bundles:
|
||||||
|
|
||||||
- Shared media galleries
|
- Shared media galleries
|
||||||
|
|
|
@ -116,6 +116,7 @@ He lay on his armour-like back, and if he lifted his head a little he could see
|
||||||
|
|
||||||
A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops
|
A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops
|
||||||
```
|
```
|
||||||
|
Hugo will take this AsciiDoc and create a table of contents store it in the page variable `.TableOfContents`, in the same as described for Markdown.
|
||||||
|
|
||||||
[conditionals]: /templates/introduction/#conditionals
|
[conditionals]: /templates/introduction/#conditionals
|
||||||
[front matter]: /content-management/front-matter/
|
[front matter]: /content-management/front-matter/
|
||||||
|
|
|
@ -30,6 +30,8 @@ This is the default configuration:
|
||||||
|
|
||||||
{{< code-toggle config="markup.goldmark" />}}
|
{{< code-toggle config="markup.goldmark" />}}
|
||||||
|
|
||||||
|
For details on the extensions, refer to [this section](https://github.com/yuin/goldmark/#built-in-extensions) of the Goldmark documentation
|
||||||
|
|
||||||
Some settings explained:
|
Some settings explained:
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
|
|
|
@ -67,7 +67,7 @@ In addition to using a single site config file, one can use the `configDir` dire
|
||||||
|
|
||||||
Considering the structure above, when running `hugo --environment staging`, Hugo will use every settings from `config/_default` and merge `staging`'s on top of those.
|
Considering the structure above, when running `hugo --environment staging`, Hugo will use every settings from `config/_default` and merge `staging`'s on top of those.
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
Default environments are __development__ with `hugo serve` and __production__ with `hugo`.
|
Default environments are __development__ with `hugo server` and __production__ with `hugo`.
|
||||||
{{%/ note %}}
|
{{%/ note %}}
|
||||||
## All Configuration Settings
|
## All Configuration Settings
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ ignoreConfig
|
||||||
: If enabled, any module configuration file, e.g. `config.toml`, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.
|
: If enabled, any module configuration file, e.g. `config.toml`, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.
|
||||||
|
|
||||||
disable
|
disable
|
||||||
: Set to `true` to disable the module off while keeping any version info in the `go.*` files.
|
: Set to `true` to disable the module while keeping any version info in the `go.*` files.
|
||||||
|
|
||||||
{{< gomodules-info >}}
|
{{< gomodules-info >}}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ The easiest way to use a Module for a theme is to import it in the config.
|
||||||
```toml
|
```toml
|
||||||
[module]
|
[module]
|
||||||
[[module.imports]]
|
[[module.imports]]
|
||||||
path = "github.com/spf13/hyde/"
|
path = "github.com/spf13/hyde"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update Modules
|
## Update Modules
|
||||||
|
|
|
@ -38,6 +38,8 @@ externals [slice]
|
||||||
{{ $externals := slice "react" "react-dom" }}
|
{{ $externals := slice "react" "react-dom" }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> Marking a package as external doesn't imply that the library can be loaded from a CDN. It simply tells Hugo not to expand/include the package in the JS file.
|
||||||
|
|
||||||
defines [map]
|
defines [map]
|
||||||
: Allow to define a set of string replacement to be performed when building. Should be a map where each key is to be replaced by its value.
|
: Allow to define a set of string replacement to be performed when building. Should be a map where each key is to be replaced by its value.
|
||||||
|
|
||||||
|
@ -66,3 +68,29 @@ Or with options:
|
||||||
{{ $built := resources.Get "scripts/main.js" | js.Build $opts }}
|
{{ $built := resources.Get "scripts/main.js" | js.Build $opts }}
|
||||||
<script type="text/javascript" src="{{ $built.RelPermalink }}" defer></script>
|
<script type="text/javascript" src="{{ $built.RelPermalink }}" defer></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Shimming a JS library
|
||||||
|
It's a very common practice to load external libraries using CDN rather than importing all packages in a single JS file, making it bulky. To do the same with Hugo, you'll need to shim the libraries as follows. In this example, `algoliasearch` and `instantsearch.js` will be shimmed.
|
||||||
|
|
||||||
|
Firstly, add the following to your project's `package.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"browser": {
|
||||||
|
"algoliasearch/lite": "./public/js/shims/algoliasearch.js",
|
||||||
|
"instantsearch.js/es/lib/main": "./public/js/shims/instantsearch.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
What this does is it tells Hugo to look for the listed packages somewhere else. Here we're telling Hugo to look for `algoliasearch/lite` and `instantsearch.js/es/lib/main` in the project's `public/js/shims` folder.
|
||||||
|
|
||||||
|
Now we'll need to create the shim JS files which export the global JS variables `module.exports = window.something`. You can create a separate shim JS file in your `assets` directory, and redirect the import paths there if you wish, but a much cleaner way is to create these files on the go, by having the following before your JS is built.
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ $a := "module.exports = window.algoliasearch" | resources.FromString "js/shims/algoliasearch.js" }}
|
||||||
|
{{ $i := "module.exports = window.instantsearch" | resources.FromString "js/shims/instantsearch.js" }}
|
||||||
|
|
||||||
|
{{/* Call RelPermalink unnecessarily to generate JS files */}}
|
||||||
|
{{ $placebo := slice $a.RelPermalink $i.RelPermalink }}
|
||||||
|
```
|
||||||
|
That's it! You should now have a browser-friendly JS which can use external JS libraries.
|
||||||
|
|
BIN
docs/content/en/news/0.75.0-relnotes/featured.png
Normal file
BIN
docs/content/en/news/0.75.0-relnotes/featured.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
|
@ -1,16 +1,15 @@
|
||||||
|
|
||||||
---
|
---
|
||||||
date: 2020-09-14
|
date: 2020-09-14
|
||||||
title: "0.75.0"
|
title: "NPM Pack"
|
||||||
description: "0.75.0"
|
description: "Hugo 0.75 comes with a new \"hugo mod npm pack\" command, several improvements re. Hugo Modules and the Node tools, and more."
|
||||||
categories: ["Releases"]
|
categories: ["Releases"]
|
||||||
---
|
---
|
||||||
|
|
||||||
Hugo `0.75.0` brings several improvements to Hugo Modules, a new CLI command to bridge the JavaScript dependencies into Hugo, a refresh of the versions of the most important upstream dependencies, and more.
|
Hugo `0.75.0` brings several improvements to Hugo Modules, a new CLI command to bridge the JavaScript dependencies into Hugo, a refresh of the versions of the most important upstream dependencies, and more. There are also some good bug fixes in this release. One notable one is covered by [this commit](https://github.com/gohugoio/hugo/commit/4055c121847847d8bd6b95a928185daee065091b) -- which covers a "stale content scenario in server" when you include content or page data via `GetPage` from a shortcode.
|
||||||
|
|
||||||
## NPM Pack
|
## NPM Pack
|
||||||
|
|
||||||
|
|
||||||
The new CLI command is called `hugo mod npm pack`. We have marked it as experimental. It works great, go ahead and use it, but we need to test this out in real projects to get a feel of it; it is likely that it will change/improve in the upcoming versions of Hugo. The command creates a consolidated `package.json` from the project and all of its [theme components](https://gohugo.io/hugo-modules/theme-components/). On version conflicts, the version closest to the project is selected. We may revise that strategy in the future ([minimal version selection](https://about.sourcegraph.com/blog/the-pain-that-minimal-version-selection-solves/) maybe?), but this should give both control and the least amount of surprise for the site owner.
|
The new CLI command is called `hugo mod npm pack`. We have marked it as experimental. It works great, go ahead and use it, but we need to test this out in real projects to get a feel of it; it is likely that it will change/improve in the upcoming versions of Hugo. The command creates a consolidated `package.json` from the project and all of its [theme components](https://gohugo.io/hugo-modules/theme-components/). On version conflicts, the version closest to the project is selected. We may revise that strategy in the future ([minimal version selection](https://about.sourcegraph.com/blog/the-pain-that-minimal-version-selection-solves/) maybe?), but this should give both control and the least amount of surprise for the site owner.
|
||||||
|
|
||||||
So, why did we do this? JavaScript is often a background actor in a Hugo project, and it doesn't make sense to publish it to a NPM registry. The JS dependencies are mostly build tools (PostCSS, TailwindCSS, Babel), `devDependencies`. This has been working fine as long as you kept the JS config files (including `package.json`) in the project, adding duplication/work when using ready-to-use theme components. These tools work best when you have everything below a single file tree, which is very much different to how [Hugo Modules](https://gohugo.io/hugo-modules/) work. An example of a module with TailwindCSS:
|
So, why did we do this? JavaScript is often a background actor in a Hugo project, and it doesn't make sense to publish it to a NPM registry. The JS dependencies are mostly build tools (PostCSS, TailwindCSS, Babel), `devDependencies`. This has been working fine as long as you kept the JS config files (including `package.json`) in the project, adding duplication/work when using ready-to-use theme components. These tools work best when you have everything below a single file tree, which is very much different to how [Hugo Modules](https://gohugo.io/hugo-modules/) work. An example of a module with TailwindCSS:
|
||||||
|
@ -44,7 +43,7 @@ const tailwind = require('tailwindcss')(tailwindConfig);
|
||||||
|
|
||||||
* We have added a `noVendor` Glob pattern config to the module config [d4611c43](https://github.com/gohugoio/hugo/commit/d4611c4322dabfd8d2520232be578388029867db) [@bep](https://github.com/bep) [#7647](https://github.com/gohugoio/hugo/issues/7647). This allows you to only vendor a subset of your dependencies.
|
* We have added a `noVendor` Glob pattern config to the module config [d4611c43](https://github.com/gohugoio/hugo/commit/d4611c4322dabfd8d2520232be578388029867db) [@bep](https://github.com/bep) [#7647](https://github.com/gohugoio/hugo/issues/7647). This allows you to only vendor a subset of your dependencies.
|
||||||
* We have added `ignoreImports` option to module imports config [20af9a07](https://github.com/gohugoio/hugo/commit/20af9a078189ce1e92a1d2047c90fba2a4e91827) [@bep](https://github.com/bep) [#7646](https://github.com/gohugoio/hugo/issues/7646), which allows you to import a module and load its config, but not follow its imports.
|
* We have added `ignoreImports` option to module imports config [20af9a07](https://github.com/gohugoio/hugo/commit/20af9a078189ce1e92a1d2047c90fba2a4e91827) [@bep](https://github.com/bep) [#7646](https://github.com/gohugoio/hugo/issues/7646), which allows you to import a module and load its config, but not follow its imports.
|
||||||
* We have deprecated `--ignoreVendor` in favour of a `--ignoreVendor`, a patch matching Glob pattern [9a1e6d15](https://github.com/gohugoio/hugo/commit/9a1e6d15a31ec667b2ff9cf20e43b1daca61e004) [@bep](https://github.com/bep). A typical use for this would be when you have vendored your dependencies, but want to edit one of them.
|
* We have deprecated `--ignoreVendor` in favour of a `--ignoreVendorPaths`, a patch matching Glob pattern [9a1e6d15](https://github.com/gohugoio/hugo/commit/9a1e6d15a31ec667b2ff9cf20e43b1daca61e004) [@bep](https://github.com/bep). A typical use for this would be when you have vendored your dependencies, but want to edit one of them.
|
||||||
|
|
||||||
|
|
||||||
## Statistics
|
## Statistics
|
||||||
|
@ -62,6 +61,10 @@ Hugo now has:
|
||||||
* 438+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
|
* 438+ [contributors](https://github.com/gohugoio/hugo/graphs/contributors)
|
||||||
* 352+ [themes](http://themes.gohugo.io/)
|
* 352+ [themes](http://themes.gohugo.io/)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
* We now build with Go 1.15, which means that we no longer build release binaries for MacOS 32-bit.
|
||||||
|
* You may now get an error message about "error calling partial: partials that returns a value needs a non-zero argument.". This error situation was not caught earlier, and comes from a limitation in Go's templates: If you use the `return` keyword in a partial, the argument you pass to that partial (e.g. the ".") cannot be zero (and 0 and "" is considered a zero argument).
|
||||||
|
|
||||||
## Enhancements
|
## Enhancements
|
||||||
|
|
||||||
### Templates
|
### Templates
|
||||||
|
|
|
@ -43,10 +43,16 @@ Setting `Paginate` to a positive value will split the list pages for the homepag
|
||||||
There are two ways to configure and use a `.Paginator`:
|
There are two ways to configure and use a `.Paginator`:
|
||||||
|
|
||||||
1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for *that page*.
|
1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for *that page*.
|
||||||
2. Select a subset of the pages with the available template functions and ordering options, and pass the slice to `.Paginate`, e.g. `{{ range (.Paginate ( first 50 .Pages.ByTitle )).Pages }}`.
|
2. Select another set of pages with the available template functions and ordering options, and pass the slice to `.Paginate`, e.g.
|
||||||
|
* `{{ range (.Paginate ( first 50 .Pages.ByTitle )).Pages }}` or
|
||||||
|
* `{{ range (.Paginate .RegularPagesRecursive).Pages }}`.
|
||||||
|
|
||||||
For a given **Page**, it's one of the options above. The `.Paginator` is static and cannot change once created.
|
For a given **Page**, it's one of the options above. The `.Paginator` is static and cannot change once created.
|
||||||
|
|
||||||
|
If you call `.Paginator` or `.Paginate` multiple times on the same page, you should ensure all the calls are identical. Once *either* `.Paginator` or `.Paginate` is called while generating a page, its result is cached, and any subsequent similar call will reuse the cached result. This means that any such calls which do not match the first one will not behave as written.
|
||||||
|
|
||||||
|
(Remember that function arguments are eagerly evaluated, so a call like `$paginator := cond x .Paginator (.Paginate .RegularPagesRecursive)` is an example of what you should *not* do. Use `if`/`else` instead to ensure exactly one evaluation.)
|
||||||
|
|
||||||
The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:
|
The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:
|
||||||
|
|
||||||
* `{{ range (.Paginator 5).Pages }}`
|
* `{{ range (.Paginator 5).Pages }}`
|
||||||
|
|
|
@ -43,7 +43,7 @@ For multilingual sites, we also create a Sitemap index. You can provide a custom
|
||||||
|
|
||||||
## Hugo’s sitemap.xml
|
## Hugo’s sitemap.xml
|
||||||
|
|
||||||
This template respects the version 0.9 of the [Sitemap Protocol](https://www.sitemaps.org/protocol.html).
|
This template respects the version 1.0 of the [Sitemap Protocol](https://www.sitemaps.org/protocol.html).
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
|
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
|
||||||
|
|
|
@ -158,11 +158,11 @@ Hugo uses both `date` and `weight` to order content within taxonomies.
|
||||||
|
|
||||||
Each piece of content in Hugo can optionally be assigned a date. It can also be assigned a weight for each taxonomy it is assigned to.
|
Each piece of content in Hugo can optionally be assigned a date. It can also be assigned a weight for each taxonomy it is assigned to.
|
||||||
|
|
||||||
When iterating over content within taxonomies, the default sort is the same as that used for section and list pages first by weight then by date. This means that if the weights for two pieces of content are the same, then the more recent content will be displayed first.
|
When iterating over content within taxonomies, the default sort is the same as that used for section and list pages: first by weight, then by date. This means that if the weights for two pieces of content are the same, then the more recent content will be displayed first.
|
||||||
|
|
||||||
The default weight for any piece of content is 0.
|
The default weight for any piece of content is 0. Zero means "does not have a weight", not "has a weight of numerical value zero".
|
||||||
|
|
||||||
Weights of zero are treated specially: if two pages have unequal weights, and one of them is zero, then the zero-weighted page will always appear after the other one, regardless of the other's weight. Zero weights should thus be used with care: for example, if both positive and negative weights are used to extend a sequence in both directions, a zero-weighted page will appear not in the middle of the list, but at the end.
|
Weights of zero are thus treated specially: if two pages have unequal weights, and one of them is zero, then the zero-weighted page will always appear after the other one, regardless of the other's weight. Zero weights should thus be used with care: for example, if both positive and negative weights are used to extend a sequence in both directions, a zero-weighted page will appear not in the middle of the list, but at the end.
|
||||||
|
|
||||||
### Assign Weight
|
### Assign Weight
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,4 @@ toc: false
|
||||||
* **Features:** inline PageDown editor, visual tree view, image upload and digital asset management with Cloudinary, site preview, continuous integration with GitHub, atomic deploy and hosting, Git and Hugo integration, autosave, custom domain, project syncing, theme cloning and management. Developers have complete control over the source code and can manage it with GitHub’s deceptively simple workflow.
|
* **Features:** inline PageDown editor, visual tree view, image upload and digital asset management with Cloudinary, site preview, continuous integration with GitHub, atomic deploy and hosting, Git and Hugo integration, autosave, custom domain, project syncing, theme cloning and management. Developers have complete control over the source code and can manage it with GitHub’s deceptively simple workflow.
|
||||||
* [DATOCMS](https://www.datocms.com) DatoCMS is a fully customizable administrative area for your static websites. Use your favorite website generator, let your clients publish new content independently, and the host the site anywhere you like.
|
* [DATOCMS](https://www.datocms.com) DatoCMS is a fully customizable administrative area for your static websites. Use your favorite website generator, let your clients publish new content independently, and the host the site anywhere you like.
|
||||||
* [Forestry.io](https://forestry.io/). Forestry is a git-backed CMS for Hugo, Gatsby, Jekyll and VuePress websites with support for GitHub, GitLab, Bitbucket and Azure Devops. Forestry provides a nice user interface to edit and model content for non technical editors. It supports S3, Cloudinary and Netlify Large Media integrations for storing media. Every time an update is made via the CMS, Forestry will commit changes back to your repo and vice-versa.
|
* [Forestry.io](https://forestry.io/). Forestry is a git-backed CMS for Hugo, Gatsby, Jekyll and VuePress websites with support for GitHub, GitLab, Bitbucket and Azure Devops. Forestry provides a nice user interface to edit and model content for non technical editors. It supports S3, Cloudinary and Netlify Large Media integrations for storing media. Every time an update is made via the CMS, Forestry will commit changes back to your repo and vice-versa.
|
||||||
* [Netlify.com](https://www.netlify.com). Netlify builds, deploys, and hosts your static website or app (Hugo, Jekyll, etc). Netlify offers a drag-and-drop interface and automatic deployments from GitHub or Bitbucket.
|
|
||||||
* **Features:** global CDN, atomic deploys, ultra-fast DNS, instant cache invalidation, high availability, automated hosting, Git integration, form submission hooks, authentication providers, and custom domains. Developers have complete control over the source code and can manage it with GitHub or Bitbucket's deceptively simple workflow.
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ publish = "public"
|
||||||
command = "hugo --gc --minify"
|
command = "hugo --gc --minify"
|
||||||
|
|
||||||
[context.production.environment]
|
[context.production.environment]
|
||||||
HUGO_VERSION = "0.74.3"
|
HUGO_VERSION = "0.75.1"
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
||||||
|
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
|
||||||
command = "hugo --gc --minify --enableGitInfo"
|
command = "hugo --gc --minify --enableGitInfo"
|
||||||
|
|
||||||
[context.split1.environment]
|
[context.split1.environment]
|
||||||
HUGO_VERSION = "0.74.3"
|
HUGO_VERSION = "0.75.1"
|
||||||
HUGO_ENV = "production"
|
HUGO_ENV = "production"
|
||||||
|
|
||||||
[context.deploy-preview]
|
[context.deploy-preview]
|
||||||
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.deploy-preview.environment]
|
[context.deploy-preview.environment]
|
||||||
HUGO_VERSION = "0.74.3"
|
HUGO_VERSION = "0.75.1"
|
||||||
|
|
||||||
[context.branch-deploy]
|
[context.branch-deploy]
|
||||||
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||||
|
|
||||||
[context.branch-deploy.environment]
|
[context.branch-deploy.environment]
|
||||||
HUGO_VERSION = "0.74.3"
|
HUGO_VERSION = "0.75.1"
|
||||||
|
|
||||||
[context.next.environment]
|
[context.next.environment]
|
||||||
HUGO_ENABLEGITINFO = "true"
|
HUGO_ENABLEGITINFO = "true"
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
Loading…
Reference in a new issue