summaryrefslogtreecommitdiffstats
path: root/helpers
AgeCommit message (Collapse)Author
2019-11-04helpers: Use pointer receiver for ContentSpecBjørn Erik Pedersen
2019-10-24deps: Update to Chroma v0.6.8 to fix a crashBjørn Erik Pedersen
Also improve relevant logging. Fixes #6450
2019-10-10helpers: Fix data race in global logger initBjørn Erik Pedersen
Fixes #6409
2019-10-07Add BaseFs to RenderingContextNiklas Fasching
The org mode renderer supports including other files [1]. We don't want to allow reading of arbitrary files (go-org defaults to ioutil.ReadFile [2]) but want to make use of the FileSystem abstractions hugo provides. For starters we will allow reading from the content directory only [1]: e.g. `#+INCLUDE: ./foo.py src python` includes `foo.py` as a python source block.
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2019-08-10Simplify codeChristian Muehlhaeuser
- Use bytes.Equal instead of bytes.Compare - Omit range's value where it's unused
2019-07-25Block symlink dir traversal for /staticBjørn Erik Pedersen
This is in line with how it behaved before, but it was lifted a little for the project mount for Hugo Modules, but that could create hard-to-detect loops.
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
This commit implements Hugo Modules. This is a broad subject, but some keywords include: * A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project. * A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects. * Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running. * Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions. * A new set of CLI commands are provided to manage all of this: `hugo mod init`, `hugo mod get`, `hugo mod graph`, `hugo mod tidy`, and `hugo mod vendor`. All of the above is backed by Go Modules. Fixes #5973 Fixes #5996 Fixes #6010 Fixes #5911 Fixes #5940 Fixes #6074 Fixes #6082 Fixes #6092
2019-06-08Improve Org mode support: Replace goorgeous with go-orgNiklas Fasching
Sadly, goorgeous has not been updated in over a year and still has a lot of open issues (e.g. no support for nested lists). go-org fixes most of those issues and supports a larger subset of Org mode syntax.
2019-04-05hugolib: Consider summary in front matter for .SummaryJim McDonald
Add the ability to have a `summary` page variable that overrides the auto-generated summary. Logic for obtaining summary becomes: * if summary divider is present in content, use the text above it * if summary variables is present in page metadata, use that * auto-generate summary from first _x_ words of the content Fixes #5800
2019-03-24all: Apply staticcheck recommendationsBjørn Erik Pedersen
2019-03-23Make Page an interfaceBjørn Erik Pedersen
The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct. This is all a preparation step for issue #5074, "pages from other data sources". But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes. Most notable changes: * The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday. This means that any markdown will partake in the global ToC and footnote context etc. * The Custom Output formats are now "fully virtualized". This removes many of the current limitations. * The taxonomy list type now has a reference to the `Page` object. This improves the taxonomy template `.Title` situation and make common template constructs much simpler. See #5074 Fixes #5763 Fixes #5758 Fixes #5090 Fixes #5204 Fixes #4695 Fixes #5607 Fixes #5707 Fixes #5719 Fixes #3113 Fixes #5706 Fixes #5767 Fixes #5723 Fixes #5769 Fixes #5770 Fixes #5771 Fixes #5759 Fixes #5776 Fixes #5777 Fixes #5778
2019-03-04Add skipHTML option to blackfriday configarrtchiu
2018-12-30Revert " Fix handling of taxonomy terms containing slashes"Bjørn Erik Pedersen
See #4090 See #5571 This reverts commit fff132537b4094221f4f099e2251f3cda613060f.
2018-12-23tpl/transform: Add transform.Unmarshal funcBjørn Erik Pedersen
Fixes #5428
2018-12-20Move the emoji parsing to pageparserBjørn Erik Pedersen
This avoids double parsing the page content when `enableEmoji=true`. This commit also adds some general improvements to the parser, making it in general much faster: ```bash benchmark old ns/op new ns/op delta BenchmarkShortcodeLexer-4 90258 101730 +12.71% BenchmarkParse-4 148940 15037 -89.90% benchmark old allocs new allocs delta BenchmarkShortcodeLexer-4 456 700 +53.51% BenchmarkParse-4 28 33 +17.86% benchmark old bytes new bytes delta BenchmarkShortcodeLexer-4 69875 81014 +15.94% BenchmarkParse-4 8128 8304 +2.17% ``` Running some site benchmarks with Emoji support turned on: ```bash benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=3,num_pages=5000,tags_per_page=5,shortcodes,render-4 924556797 818115620 -11.51% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=3,num_pages=5000,tags_per_page=5,shortcodes,render-4 4112613 4133787 +0.51% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=3,num_pages=5000,tags_per_page=5,shortcodes,render-4 426982864 424363832 -0.61% ``` Fixes #5534
2018-12-11Add /config dir supportBjørn Erik Pedersen
This commit adds support for a configuration directory (default `config`). The different pieces in this puzzle are: * A new `--environment` (or `-e`) flag. This can also be set with the `HUGO_ENVIRONMENT` OS environment variable. The value for `environment` defaults to `production` when running `hugo` and `development` when running `hugo server`. You can set it to any value you want (e.g. `hugo server -e "Sensible Environment"`), but as it is used to load configuration from the file system, the letter case may be important. You can get this value in your templates with `{{ hugo.Environment }}`. * A new `--configDir` flag (defaults to `config` below your project). This can also be set with `HUGO_CONFIGDIR` OS environment variable. If the `configDir` exists, the configuration files will be read and merged on top of each other from left to right; the right-most value will win on duplicates. Given the example tree below: If `environment` is `production`, the left-most `config.toml` would be the one directly below the project (this can now be omitted if you want), and then `_default/config.toml` and finally `production/config.toml`. And since these will be merged, you can just provide the environment specific configuration setting in you production config, e.g. `enableGitInfo = true`. The order within the directories will be lexical (`config.toml` and then `params.toml`). ```bash config ├── _default │   ├── config.toml │   ├── languages.toml │   ├── menus │   │   ├── menus.en.toml │   │   └── menus.zh.toml │   └── params.toml ├── development │   └── params.toml └── production ├── config.toml └── params.toml ``` Some configuration maps support the language code in the filename (e.g. `menus.en.toml`): `menus` (`menu` also works) and `params`. Also note that the only folders with "a meaning" in the above listing is the top level directories below `config`. The `menus` sub folder is just added for better organization. We use `TOML` in the example above, but Hugo also supports `JSON` and `YAML` as configuration formats. These can be mixed. Fixes #5422
2018-12-06Add tpl/site and tpl/hugoBjørn Erik Pedersen
This means that the current `.Site` and ´.Hugo` is available as a globals, so you can do `site.IsServer`, `hugo.Version` etc. Fixes #5470 Fixes #5467 Fixes #5503
2018-11-28releaser: Prepare repository for 0.53-DEVhugoreleaser
[ci skip]
2018-11-28releaser: Bump versions for release of 0.52hugoreleaser
[ci skip]
2018-11-15Fix Permalink for resource, baseURL with path and canonifyURLs setBjørn Erik Pedersen
Fixes #5226
2018-11-14helpers: Add a comment about file mode for new filesBjørn Erik Pedersen
See #5434
2018-11-13Add a consolidated file cacheBjørn Erik Pedersen
This commits reworks how file caching is performed in Hugo. Now there is only one way, and it can be configured. This is the default configuration: ```toml [caches] [caches.getjson] dir = ":cacheDir" maxAge = -1 [caches.getcsv] dir = ":cacheDir" maxAge = -1 [caches.images] dir = ":resourceDir/_gen" maxAge = -1 [caches.assets] dir = ":resourceDir/_gen" maxAge = -1 ``` You can override any of these cache setting in your own `config.toml`. The placeholders explained: `:cacheDir`: This is the value of the `cacheDir` config option if set (can also be set via OS env variable `HUGO_CACHEDIR`). It will fall back to `/opt/build/cache/hugo_cache/` on Netlify, or a `hugo_cache` directory below the OS temp dir for the others. `:resourceDir`: This is the value of the `resourceDir` config option. `maxAge` is the time in seconds before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. This means that if you run your builds on Netlify, all caches configured with `:cacheDir` will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see https://github.com/bep/hugo-sass-test/blob/6c3960a8f4b90e8938228688bc49bdcdd6b2d99e/.circleci/config.yml Fixes #5404
2018-11-07releaser: Prepare repository for 0.52-DEVhugoreleaser
[ci skip]
2018-11-07releaser: Bump versions for release of 0.51hugoreleaser
[ci skip]
2018-10-29releaser: Prepare repository for 0.51-DEVhugoreleaser
[ci skip]
2018-10-29releaser: Bump versions for release of 0.50hugoreleaser
[ci skip]
2018-10-16commands: Show server error info in browserBjørn Erik Pedersen
The main item in this commit is showing of errors with a file context when running `hugo server`. This can be turned off: `hugo server --disableBrowserError` (can also be set in `config.toml`). But to get there, the error handling in Hugo needed a revision. There are some items left TODO for commits soon to follow, most notable errors in content and config files. Fixes #5284 Fixes #5290 See #5325 See #5324
2018-10-11helpers: Call rst2html directly on *nixShreyansh Khajanchi
Initially, rst2html was called via the python interpreter which would fail if the script was wrapped in a launcher as on NixOS. Ideally, on *nix, binaries should be invoked directly to ensure that shebangs work properly as is being done now. Handle the case of windows as it doesn't do shebangs.
2018-10-03helpers: Consolidate MakeSegment vs MakePathSanitizedBjørn Erik Pedersen
In short: * Avoid double tolower in MakeSegment * Use MakePathSanitized for taxonomies in pageToPermalinkTitle; this matches what MakeSegment does. * Move the "double hyphen and space" logic into UnicodeSanitize The last bullet may be slightly breaking for some that now does not get the "--" in some URLs, but we need to reduce the amount of URL logic. See #4926
2018-09-24releaser: Prepare repository for 0.50-DEVhugoreleaser
[ci skip]
2018-09-24releaser: Bump versions for release of 0.49hugoreleaser
[ci skip]
2018-09-07helpers: Fix golint issuesCameron Moore
helpers/general.go:448:1: comment on exported function DiffStrings should be of the form "DiffStrings ..." helpers/hugo.go:42:6: exported type HugoVersionString should have comment or be unexported helpers/hugo.go:48:1: exported method HugoVersion.Version should have comment or be unexported helpers/hugo.go:56:1: comment on exported method HugoVersionString.Compare should be of the form "Compare ..." helpers/hugo.go:62:1: comment on exported method HugoVersionString.Eq should be of the form "Eq ..." helpers/path.go:548:1: comment on exported function OpenFilesForWriting should be of the form "OpenFilesForWriting ..." helpers/processing_stats.go:24:6: exported type ProcessingStats should have comment or be unexported helpers/processing_stats.go:55:1: exported function NewProcessingStats should have comment or be unexported helpers/processing_stats.go:59:1: exported method ProcessingStats.Incr should have comment or be unexported helpers/processing_stats.go:63:1: exported method ProcessingStats.Add should have comment or be unexported helpers/processing_stats.go:67:1: exported method ProcessingStats.Table should have comment or be unexported helpers/processing_stats.go:83:1: exported function ProcessingStatsTable should have comment or be unexported
2018-08-29releaser: Prepare repository for 0.49-DEVhugoreleaser
[ci skip]
2018-08-29releaser: Bump versions for release of 0.48hugoreleaser
[ci skip]
2018-08-28helpers: Fix permissions when creating new foldersBjørn Erik Pedersen
This was mistakingly changed from 07777 (rwx, rw, r before umask) to 0755 in Hugo 0.37. This commit reverts to the old value. Fixes #5128
2018-08-22 Fix handling of taxonomy terms containing slashesCameron Moore
Fixes #4090
2018-08-20releaser: Prepare repository for 0.48-DEVhugoreleaser
[ci skip]
2018-08-20releaser: Bump versions for release of 0.47.1hugoreleaser
[ci skip]
2018-08-17releaser: Prepare repository for 0.48-DEVhugoreleaser
[ci skip]
2018-08-17releaser: Bump versions for release of 0.47hugoreleaser
[ci skip]
2018-08-13Fix Resource output in multihost setupsBjørn Erik Pedersen
In Hugo 0.46 we made the output of what you get from resources.Get and similar static, i.e. language agnostic. This makes total sense, as it is wasteful and time-consuming to do SASS/SCSS/PostCSS processing for lots of languages when the output is lots of duplicates with different filenames. But since we now output the result once only, this had a negative side effect for multihost setups: We publish the resource once only to the root folder (i.e. not to the language "domain folder"). This commit removes the language code from the processed image keys. This creates less duplication in the file cache, but it means that you should do a `hugo --gc` to clean up stale files. Fixes #5058
2018-08-06Add support for minification of final outputBjørn Erik Pedersen
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar. This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON. To enable, run Hugo with the `--minify` flag: ```bash hugo --minify ``` This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain. Fixes #1251
2018-08-01releaser: Prepare repository for 0.47-DEVhugoreleaser
[ci skip]
2018-08-01releaser: Bump versions for release of 0.46hugoreleaser
[ci skip]
2018-07-25releaser: Prepare repository for 0.46-DEVhugoreleaser
[ci skip]
2018-07-25releaser: Bump versions for release of 0.45.1hugoreleaser
[ci skip]
2018-07-22releaser: Prepare repository for 0.46-DEVhugoreleaser
[ci skip]
2018-07-22releaser: Bump versions for release of 0.45hugoreleaser
[ci skip]
2018-07-13releaser: Prepare repository for 0.45-DEVhugoreleaser
[ci skip]