diff options
28 files changed, 9235 insertions, 90 deletions
diff --git a/docs/content/en/content-management/related.md b/docs/content/en/content-management/related.md index ce0cafa09..ec3c3dd6f 100644 --- a/docs/content/en/content-management/related.md +++ b/docs/content/en/content-management/related.md @@ -84,6 +84,8 @@ related: weight: 10 {{< /code-toggle >}} +Note that if you have configured `tags` as a taxonomy, `tags` will also be added to the default configuration abve with the weight of `80`. + Custom configuration should be set using the same syntax. {{% note %}} diff --git a/docs/content/en/functions/path.Split.md b/docs/content/en/functions/path.Split.md index d6bc15ce9..2d6aff6bb 100644 --- a/docs/content/en/functions/path.Split.md +++ b/docs/content/en/functions/path.Split.md @@ -25,7 +25,7 @@ If there is no slash in `PATH`, it returns an empty directory and the base is se **Note:** On Windows, `PATH` is converted to slash (`/`) separators. ``` -{{ path.Split "a/news.html" }} → "a/", "news.html" -{{ path.Split "news.html" }} → "", "news.html" -{{ path.Split "a/b/c" }} → "a/b/", "c" +{{ $dirFile := path.Split "a/news.html" }} → $dirDile.Dir → "a/", $dirFile.File → "news.html" +{{ $dirFile := path.Split "news.html" }} → $dirDile.Dir → "", $dirDile.File → "news.html" +{{ $dirFile := path.Split "a/b/c" }} → $dirDile.Dir → "a/b/", $dirDile.File → "c" ``` diff --git a/docs/content/en/functions/substr.md b/docs/content/en/functions/substr.md index feb25aa1b..c02141ab2 100644 --- a/docs/content/en/functions/substr.md +++ b/docs/content/en/functions/substr.md @@ -26,6 +26,21 @@ To extract characters from the end of the string, use a negative start number. In addition, borrowing from the extended behavior described at https://php.net substr, if `length` is given and is negative, that number of characters will be omitted from the end of string. ``` -{{substr "BatMan" 0 -3}} → "Bat" -{{substr "BatMan" 3 3}} → "Man" +{{ substr "abcdef" 0 }} → "abcdef" +{{ substr "abcdef" 1 }} → "bcdef" + +{{ substr "abcdef" 0 1 }} → "a" +{{ substr "abcdef" 1 1 }} → "b" + +{{ substr "abcdef" 0 -1 }} → "abcde" +{{ substr "abcdef" 1 -1 }} → "bcde" + +{{ substr "abcdef" -1 }} → "f" +{{ substr "abcdef" -2 }} → "ef" + +{{ substr "abcdef" -1 1 }} → "f" +{{ substr "abcdef" -2 1 }} → "e" + +{{ substr "abcdef" -3 -1 }} → "de" +{{ substr "abcdef" -3 -2 }} → "d" ``` diff --git a/docs/content/en/getting-started/configuration.md b/docs/content/en/getting-started/configuration.md index fbfa676bf..97763c002 100644 --- a/docs/content/en/getting-started/configuration.md +++ b/docs/content/en/getting-started/configuration.md @@ -326,7 +326,7 @@ writeStats {{< new-in "0.69.0" >}} : When enabled, a file named `hugo_stats.json` will be written to your project root with some aggregated data about the build, e.g. list of HTML entities published to be used to do [CSS pruning](/hugo-pipes/postprocess/#css-purging-with-postcss). If you're only using this for the production build, you should consider placing it below [config/production](/getting-started/configuration/#configuration-directory). It's also worth mentioning that, due to the nature of the partial server builds, new HTML entities will be added when you add or change them while the server is running, but the old values will not be removed until you restart the server or run a regular `hugo` build. noJSConfigInAssets {{< new-in "0.78.0" >}} -: Turn off writing a `jsconfig.js` into your `/assets` folder with mapping of imports from running [js.Build](https://gohugo.io/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written. +: Turn off writing a `jsconfig.json` into your `/assets` folder with mapping of imports from running [js.Build](https://gohugo.io/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written. ## Configure Server diff --git a/docs/content/en/hugo-pipes/babel.md b/docs/content/en/hugo-pipes/babel.md index 9688626d9..76a1d441d 100755 --- a/docs/content/en/hugo-pipes/babel.md +++ b/docs/content/en/hugo-pipes/babel.md @@ -29,7 +29,7 @@ If you are using the Hugo Snap package, Babel and plugin(s) need to be installed {{< new-in "v0.75.0" >}} -In Hugo `v0.75` we improved the way we resolve JS configuration and dependencies. One of them is that we now adds the main project's `node_modules` to `NODE_PATH` when running Babel and similar tools. There are some known [issues](https://github.com/babel/babel/issues/5618) with Babel in this area, so if you have a `babel.config.js` living in a Hugo Module (and not in the project itself), we recommend using `require` to load the presets/plugins, e.g.: +In Hugo `v0.75` we improved the way we resolve JS configuration and dependencies. One of them is that we now add the main project's `node_modules` to `NODE_PATH` when running Babel and similar tools. There are some known [issues](https://github.com/babel/babel/issues/5618) with Babel in this area, so if you have a `babel.config.js` living in a Hugo Module (and not in the project itself), we recommend using `require` to load the presets/plugins, e.g.: ```js diff --git a/docs/content/en/hugo-pipes/js.md b/docs/content/en/hugo-pipes/js.md index fd8697264..a34454a93 100644 --- a/docs/content/en/hugo-pipes/js.md +++ b/docs/content/en/hugo-pipes/js.md @@ -115,7 +115,7 @@ And then in your JS file: import * as params from '@params'; ``` -Hugo will, by default, generate a `assets/jsconfig.js` file that maps the imports. This is useful for navigation/intellisense help inside code editors, but if you don't need/want it, you can [turn it off](/getting-started/configuration/#configure-build). +Hugo will, by default, generate a `assets/jsconfig.json` file that maps the imports. This is useful for navigation/intellisense help inside code editors, but if you don't need/want it, you can [turn it off](/getting-started/configuration/#configure-build). @@ -147,27 +147,27 @@ Or with options: #### 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. +It's a common practice to load external libraries using a content delivery network (CDN) rather than importing all packages in a single JS file. To load scripts from a CDN with Hugo, you'll need to shim the libraries as follows. In this example, `react` and `react-dom` will be shimmed. -Firstly, add the following to your project's `package.json`: +First, add React and ReactDOM [CDN script tags](https://reactjs.org/docs/add-react-to-a-website.html#tip-minify-javascript-for-production) in your HTML template files. Then create `assets/js/shims/react.js` and `assets/js/shims/react-dom.js` with the following contents: +```js +// In assets/js/shims/react.js +module.exports = window.React; + +// In assets/js/shims/react-dom.js +module.exports = window.ReactDOM; +``` + +Finally, 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" + "react": "./assets/js/shims/react.js", + "react-dom": "./assets/js/shims/react-dom.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. +This tells Hugo's `js.Build` command to look for `react` and `react-dom` in the project's `assets/js/shims` folder. Note that the `browser` field in your `package.json` file will cause React and ReactDOM to be excluded from your JavaScript bundle. Therefore, **it is unnecessary to add them to the `js.Build` command's `externals` argument.** -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. diff --git a/docs/content/en/hugo-pipes/scss-sass.md b/docs/content/en/hugo-pipes/scss-sass.md index 5f51e24c9..bdedbd961 100755 --- a/docs/content/en/hugo-pipes/scss-sass.md +++ b/docs/content/en/hugo-pipes/scss-sass.md @@ -27,7 +27,7 @@ Any SASS or SCSS file can be transformed into a CSS file using `resources.ToCSS` transpiler [string] {{< new-in "0.80.0" >}} -: The `transpiler` to use, valid values are `libsass` (default) and `dartsass`. Note that the Embedded Dart Sass project is still in beta (beta 5 at the time of writing). The release is scheduled for Q1 2021. We will try to improve the installation process by then, but if you want to use Hugo with Dart Sass you need to download a release binary from [Embedded Dart Sass](https://github.com/sass/dart-sass-embedded/releases) and make sure it's in your PC's `$PATH` (or `%PATH%` on Windows). +: The `transpiler` to use, valid values are `libsass` (default) and `dartsass`. Note that the Embedded Dart Sass project is still in beta (beta 5 at the time of writing). The release is scheduled for Q1 2021. We will try to improve the installation process by then, but if you want to use Hugo with Dart Sass you need to download a release binary from [Embedded Dart Sass](https://github.com/sass/dart-sass-embedded/releases) (beta 5) and make sure it's in your PC's `$PATH` (or `%PATH%` on Windows). targetPath [string] : If not set, the resource's target path will be the asset file original path with its extension replaced by `.css`. diff --git a/docs/content/en/news/0.78.0-relnotes/index.md b/docs/content/en/news/0.78.0-relnotes/index.md index fcc20c066..25b0fd4d8 100644 --- a/docs/content/en/news/0.78.0-relnotes/index.md +++ b/docs/content/en/news/0.78.0-relnotes/index.md @@ -12,7 +12,7 @@ Some notes on the improvements in this release: * Now `js.Build` fully supports the virtual union filesystem in [Hugo Modules](https://gohugo.io/hugo-modules/). Any import inside your JavaScript components will resolve starting from the top component mount inside `/assets` with a fallback to the traditional "JS way" (`node_modules` etc.) * You can now pass configuration data from the templates to your scripts via a new `params` option. -* Hugo now writes a `jsconfig.js` file inside `/assets` (you can turn it off) with import mappings to help editors such as VS Code with intellisense/navigation, which is especially useful when there is no common root and the source lives inside some temporary directory. +* Hugo now writes a `jsconfig.json` file inside `/assets` (you can turn it off) with import mappings to help editors such as VS Code with intellisense/navigation, which is especially useful when there is no common root and the source lives inside some temporary directory. * We have also improved the build errors you get from `js.Build`. In server mode you will get a preview of the failing lines and in the console you will get a link to the location. Read more about this in [the documentation](https://gohugo.io/hugo-pipes/js/), but a short usage example would look like: diff --git a/docs/content/en/news/0.79.0-relnotes/featured.png b/docs/content/en/news/0.79.0-relnotes/featured.png Binary files differnew file mode 100644 index 000000000..f1b7686da --- /dev/null +++ b/docs/content/en/news/0.79.0-relnotes/featured.png diff --git a/docs/content/en/news/0.79.0-relnotes/index.md b/docs/content/en/news/0.79.0-relnotes/index.md index a8debd9a2..23ed1ef2e 100644 --- a/docs/content/en/news/0.79.0-relnotes/index.md +++ b/docs/content/en/news/0.79.0-relnotes/index.md @@ -1,12 +1,12 @@ --- date: 2020-11-27 -title: "0.79.0" -description: "0.79.0" +title: "Hugo 0.79.0: Black Friday Edition" +description: "Hugo 0.79.0 brings .Params to menus, snake_case support for OS environment config, and a refresh of upstream dependencies (Chroma, ESBuild etc.)." categories: ["Releases"] --- - Hugo `0.79.0` is a small, but useful release. You can now set custom `.Params` in your [menu](https://gohugo.io/content-management/menus/) configuration, and you can now also override deeply nested snake_cased configuration variables with [OS environment variables](https://gohugo.io/getting-started/configuration/#configure-with-environment-variables). Other than that we have refreshed all the core upstream dependencies. A special thanks to [@alecthomas](https://github.com/alecthomas) (some new [Chroma lexers](https://github.com/alecthomas/chroma/releases/tag/v0.8.2) and fixes) and [@evanw](https://github.com/evanw) ([ESBuild](https://github.com/evanw/esbuild)). +Hugo `0.79.0` is a small, but useful release. You can now set custom `.Params` in your [menu](https://gohugo.io/content-management/menus/) configuration, and you can now also override deeply nested snake_cased configuration variables with [OS environment variables](https://gohugo.io/getting-started/configuration/#configure-with-environment-variables). Other than that we have refreshed all the core upstream dependencies. A special thanks to [@alecthomas](https://github.com/alecthomas) (some new [Chroma lexers](https://github.com/alecthomas/chroma/releases/tag/v0.8.2) and fixes) and [@evanw](https://github.com/evanw) ([ESBuild](https://github.com/evanw/esbuild)). This release represents **33 contributions by 8 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout [@AdamKorcz](https://github.com/AdamKorcz), and [@davidejones](https://github.com/davidejones) for their ongoing contributions. And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the themes site in pristine condition and to [@davidsneighbour](https://github.com/davidsneighbour), [@coliff](https://github.com/coliff) and [@kaushalmodi](https://github.com/kaushalmodi) for all the great work on the documentation site. diff --git a/docs/content/en/news/0.79.1-relnotes/index.md b/docs/content/en/news/0.79.1-relnotes/index.md index 76b431223..2a3f32765 100644 --- a/docs/content/en/news/0.79.1-relnotes/index.md +++ b/docs/content/en/news/0.79.1-relnotes/index.md @@ -1,19 +1,22 @@ --- date: 2020-12-19 -title: "Hugo 0.79.1: A couple of Bug Fixes" -description: "This version fixes a couple of bugs introduced in 0.79.0." +title: "Hugo 0.79.1: One Security Patch for Hugo on Windows" +description: "Disallow running of e.g. Pandoc in the current directory." categories: ["Releases"] images: - images/blog/hugo-bug-poster.png --- - +Hugo depends on Go's `os/exec` for certain features, e.g. for rendering of Pandoc documents if these binaries are found in the system `%PATH%` on Windows. However, if a malicious file with the same name (`exe` or `bat`) was found in the current working directory at the time of running `hugo`, the malicious command would be invoked instead of the system one. -This is a bug-fix release with one important fix. +Windows users who ran `hugo` inside untrusted Hugo sites were affected. -* Improve LookPath [4a8267d6](https://github.com/gohugoio/hugo/commit/4a8267d64a40564aced0695bca05249da17b0eab) [@bep](https://github.com/bep) +The origin of this issue comes from Go, see https://github.com/golang/go/issues/38736 +We have fixed this in Hugo by [using](https://github.com/gohugoio/hugo/commit/4a8267d64a40564aced0695bca05249da17b0eab) a patched version of `exec.LookPath` from https://github.com/cli/safeexec (thanks to [@mislav](https://github.com/mislav) for the implementation). + +Thanks to [@Ry0taK](https://github.com/Ry0taK) for the bug report. diff --git a/docs/content/en/news/0.80.0-relnotes/featured.png b/docs/content/en/news/0.80.0-relnotes/featured.png Binary files differnew file mode 100644 index 000000000..09308b04c --- /dev/null +++ b/docs/content/en/news/0.80.0-relnotes/featured.png diff --git a/docs/content/en/news/0.80.0-relnotes/index.md b/docs/content/en/news/0.80.0-relnotes/index.md index 48183ff47..1c390b685 100644 --- a/docs/content/en/news/0.80.0-relnotes/index.md +++ b/docs/content/en/news/0.80.0-relnotes/index.md @@ -1,12 +1,12 @@ --- date: 2020-12-31 -title: "0.80.0" -description: "0.80.0" +title: "Hugo 0.80: Last Release of 2020!" +description: "This release brings Dart Sass support, a new image overlay function, and more." categories: ["Releases"] --- - The last Hugo release of the year brings a new [images.Overlay](https://gohugo.io/functions/images/#overlay) filter to overlay an image on top of another, e.g. for watermarking, and [Dart Sass](https://gohugo.io/hugo-pipes/scss-sass/#options) support. +The last Hugo release of the year brings a new [images.Overlay](https://gohugo.io/functions/images/#overlay) filter to overlay an image on top of another, e.g. for watermarking, and [Dart Sass](https://gohugo.io/hugo-pipes/scss-sass/#options) support. This release represents **29 contributions by 12 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@moorereason](https://github.com/moorereason), and [@davidsneighbour](https://github.com/davidsneighbour) for their ongoing contributions. And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the themes site in pristine condition and to [@davidsneighbour](https://github.com/davidsneighbour), [@coliff](https://github.com/coliff) and [@kaushalmodi](https://github.com/kaushalmodi) for all the great work on the documentation site. diff --git a/docs/content/en/news/hugo-macos-intel-vs-arm/featured.png b/docs/content/en/news/hugo-macos-intel-vs-arm/featured.png Binary files differnew file mode 100644 index 000000000..30e73ad4e --- /dev/null +++ b/docs/content/en/news/hugo-macos-intel-vs-arm/featured.png diff --git a/docs/content/en/news/hugo-macos-intel-vs-arm/index.html b/docs/content/en/news/hugo-macos-intel-vs-arm/index.html new file mode 100644 index 000000000..9bc83df5d --- /dev/null +++ b/docs/content/en/news/hugo-macos-intel-vs-arm/index.html @@ -0,0 +1,9139 @@ +--- +title: "Hugo on Apple M1" +date: 2020-12-10 +description: "The new Mac Mini M1 base model is blazing fast! We have run the Hugo benchmarks comparing it to a MacBook four times more expensive." +--- + +<p><i>By <a href="https://github.com/bep/">bep</a></i></p> + +<p> + The table below shows all of Hugo's benchmarks run on both a MacBook with Intel CPU and a Mac Mini M1 with an ARM CPU. +</p> +<p>Some notes: + + <ul> + <li>The Intel Mac is a 2019 16 inch MacBook with 2,3 GHz 8-Core Intel Core i9 with 32 GB ram.</li> + <li>The ARM Mac is a new Mac Mini M1 base model with 8 GB of ram</li> + <li>The benchmarks are run with <code>go test -test.run=NONE -bench="Benchmark" -test.benchmem=true -cpu=8 -count=4 ./...</code>. Since the M1 does not have a concept of Turbo Boost, I kept that on when running the Intel benchmarks.</li> + <li>The right column is the Mac Mini, negative (black) numbers are good, positive numbers (red) are not so good.</li> + <li>Go is compiled from the latest source: <code>go version devel +5627a4dc30 Wed Dec 9 16:57:37 2020 +0000 darwin/arm64</code></li> + </ul> +</p> + +<p> + This test isn't exactly comparing apples with apples (pun intended); this is a 4K USD computer compared to a 1K computer, but that makes the performance of the Mac Mini even more impressive. +</p> + +<p> + There are some areas where the Intel still outshines the ARM, and that is most likely areas with highly optimized assembly code, and this will certainly improve. More benchmarks can be found <a href="https://roland.zone/m1-go-benchmarks/">here</a>. +</p> + +<p> + You probably want to watch <a href="https://github.com/golang/go/issues/42756">issue</a> to track when we can get a Go release with MacOS M1 support. A couple of months? +</p> + +<p> + Also, this <a href="https://docs.google.com/document/d/1iWUstb66v66tTVxQWNMZ1BehgNzEmykzqDCUp5l8ip8/edit">work document</a> is a great resource for getting a native Go development environment up and running on the M1. +</p> + +<h2>Benchstat Output</h2> + +<style> + td { + padding: 10px; + } + + th, + td { + border: none; + } +</style> +<table class="benchstat oldnew" style="border-collapse: collapse; width: 100%"> + <tr class="configs"> + <th style="text-align: left;"></th> + <th> + hugo-intel.txt + </th> + <th> + hugo-m1.txt + </th> + </tr> + <tbody> + <tr> + <th style="text-align: left;"></th> + <th colspan="2" class="metric" style=""> + time/op + </th> + <th style=""> + delta + </th> + </tr> + <tr class="group"> + <th colspan="4" style="text-align: left;"> + github.com/gohugoio/hugo/common/hreflect + </th> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + IsTruthFul-8 + </td> + <td> + 15.0ns ± 3% + </td> + <td> + 12.6ns ± 3% + </td> + <td class="delta" style="font-weight: bold;"> + −16.31% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="group"> + <th colspan="4" style="text-align: left;"> + github.com/gohugoio/hugo/common/maps + </th> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + ScratchGet-8 + </td> + <td> + 15.1ns ± 1% + </td> + <td> + 13.8ns ± 0% + </td> + <td class="delta" style="font-weight: bold;"> + −8.74% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="group"> + <th colspan="4" style="text-align: left;"> + github.com/gohugoio/hugo/helpers + </th> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + StripHTML-8 + </td> + <td> + 2.02µs ± 0% + </td> + <td> + 1.61µs ± 0% + </td> + <td class="delta" style="font-weight: bold;"> + −20.15% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + TestTruncateWordsToWholeSentence-8 + </td> + <td> + 50.1ns ± 2% + </td> + <td> + 45.1ns ± 0% + </td> + <td class="delta" style="font-weight: bold;"> + −9.98% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + TestTruncateWordsToWholeSentenceOld-8 + </td> + <td> + 4.23µs ± 2% + </td> + <td> + 3.15µs ± 0% + </td> + <td class="delta" style="font-weight: bold;"> + −25.53% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + TotalWords-8 + </td> + <td> + 6.38µs ± 2% + </td> + <td> + 5.90µs ± 0% + </td> + <td class="delta" style="font-weight: bold;"> + −7.63% + </td> + <td class="note"> + (p=0.029 n=4+4) + </td> + </tr> + <tr class="better"> + <td style="text-align: right;padding: 0em 1em;"> + EmojiKyokomiFprint-8 + </td> + <td> + 30.9µs ± 5% + </td> |