hugo/helpers
Bjørn Erik Pedersen 68bf1511f2
hugolib: Extract date and slug from filename
This commit makes it possible to extract the date from the content filename. Also, the filenames in these cases will make for very poor permalinks, so we will also use the remaining part as the page `slug` if that value is not set in front matter.

This should make it easier to move content from Jekyll to Hugo.

To enable, put this in your `config.toml`:

```toml
[frontmatter]
date  = [":filename", ":default"]
```

This commit is also a spring cleaning of how the different dates are configured in Hugo. Hugo will check for dates following the configuration from left to right, starting with `:filename` etc.

So, if you want to use the `file modification time`, this can be a good configuration:

 ```toml
[frontmatter]
date = [ "date",":fileModTime", ":default"]
lastmod = ["lastmod" ,":fileModTime", ":default"]
```

The current `:default` values for the different dates are

```toml
[frontmatter]
date = ["date","publishDate", "lastmod"]
lastmod = ["lastmod", "date","publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
```

The above will now be the same as:

```toml
[frontmatter]
date = [":default"]
lastmod = [":default"]
publishDate = [":default"]
expiryDate = [":default"]
```

Note:

* We have some built-in aliases to the above: lastmod => modified, publishDate => pubdate, published and expiryDate => unpublishdate.
* If you want a new configuration for, say, `date`, you can provide only that line, and the rest will be preserved.
* All the keywords to the right that does not start with a ":" maps to front matter parameters, and can be any date param (e.g. `myCustomDateParam`).
* The keywords to the left are the **4 predefined dates in Hugo**, i.e. they are constant values.
* The current "special date handlers" are `:fileModTime` and `:filename`. We will soon add `:git` to that list.

Fixes #285
Closes #3310
Closes #3762
Closes #4340
2018-03-11 18:26:18 +01:00
..
baseURL.go Add some missing doc comments 2017-08-03 15:57:51 +02:00
baseURL_test.go all: Propagate baseURL error to the callers 2017-03-27 15:43:56 +02:00
content.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
content_renderer.go helpers: Avoid unescape in highlight 2018-01-23 09:48:04 +01:00
content_renderer_test.go Reuse the BlackFriday instance when possible 2017-12-16 19:44:33 +01:00
content_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
emoji.go helpers: Use iterate operator by int in Emojify 2016-11-23 09:13:00 +01:00
emoji_test.go Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
general.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
general_test.go helpers: Avoid writing the last MD5 buff part twice 2017-12-28 22:52:27 +01:00
hugo.go releaser: Prepare repository for 0.38-DEV 2018-03-07 17:58:48 +00:00
hugo_test.go Properly handle -DEV suffix when comparing Hugo versions 2018-02-22 17:16:42 +01:00
language.go Fix language params handling 2018-01-30 18:53:07 +01:00
language_test.go Fix language params handling 2018-01-30 18:53:07 +01:00
path.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
path_test.go Run gofmt -s with Go 1.10 2018-02-21 09:59:33 +01:00
pathspec.go Fix URLs for bundle resources in multihost mode 2018-01-06 10:29:13 +01:00
pathspec_test.go Fix URLs for bundle resources in multihost mode 2018-01-06 10:29:13 +01:00
processing_stats.go Run gofmt -s with Go 1.10 2018-02-21 09:59:33 +01:00
pygments.go Add table linenos support for Chroma highlighter 2017-10-14 16:00:27 +02:00
pygments_test.go Add table linenos support for Chroma highlighter 2017-10-14 16:00:27 +02:00
testhelpers_test.go Use Chroma as new default syntax highlighter 2017-09-25 08:59:02 +02:00
url.go Fix URLs for bundle resources in multihost mode 2018-01-06 10:29:13 +01:00
url_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00