hugo/hugolib
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
..
pagemeta hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
testdata hugolib: Add test for image processing from shortcodes 2018-01-01 12:11:36 +01:00
404_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
alias.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
alias_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
author.go Revert the "standardize author data" 2016-09-18 19:16:39 +02:00
case_insensitive_test.go Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
config.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
config_test.go Add support for multiple config files via --config a.toml,b.toml,c.toml 2017-08-09 20:13:02 +02:00
datafiles_test.go Add support for YAML array data files 2018-02-12 17:14:40 +01:00
disableKinds_test.go Run gofmt to get imports in line vs gohugoio/hugo 2017-06-13 19:12:10 +02:00
embedded_shortcodes_test.go Add "target" and "rel" parameters to figure shortcode 2018-02-09 22:27:58 +01:00
fileInfo.go Fix handling of top-level page bundles 2018-01-27 19:13:34 +01:00
fileInfo_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
gitinfo.go hugolib: Continue GitInfo lookup on error 2018-02-22 17:21:09 +01:00
hugo_info.go Make ge, le etc. work with the Hugo Version number 2018-02-22 09:15:12 +01:00
hugo_info_test.go Make ge, le etc. work with the Hugo Version number 2018-02-22 09:15:12 +01:00
hugo_sites.go Run gofmt -s with Go 1.10 2018-02-21 09:59:33 +01:00
hugo_sites_build.go Add headless bundle support 2018-01-24 09:00:21 +01:00
hugo_sites_build_test.go Fix language params handling 2018-01-30 18:53:07 +01:00
hugo_sites_multihost_test.go Fix URLs for bundle resources in multihost mode 2018-01-06 10:29:13 +01:00
hugolib.debug Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
media.go Fix copyright headers in source files 2015-12-07 19:57:01 +01:00
menu.go hugolib: Remove unused code 2018-01-25 17:14:03 +01:00
menu_test.go Add .Title and .Page to MenuEntry 2017-12-15 18:49:21 +01:00
multilingual.go Fix language params handling 2018-01-30 18:53:07 +01:00
node_as_page_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
page.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
page_bundler.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_bundler_capture.go Add a way to disable one or more languages 2018-01-26 14:04:14 +01:00
page_bundler_capture_test.go Fix handling of top-level page bundles 2018-01-27 19:13:34 +01:00
page_bundler_handlers.go hugolib: Remove unused code 2018-01-25 17:14:03 +01:00
page_bundler_test.go Fix handling of top-level page bundles 2018-01-27 19:13:34 +01:00
page_collections.go hugolib: Avoid scanning entire site to find the home 2018-02-25 10:50:44 +01:00
page_collections_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
page_output.go hugolib: Improve error message in .Render 2018-02-13 09:01:47 +01:00
page_paths.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
page_paths_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_permalink_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
page_resource.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
page_taxonomy_test.go hugolib: Do not tolower result from Page.GetParam 2017-12-29 08:58:38 +01:00
page_test.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
page_time_integration_test.go all: Update textual references in Go source to point to gohugoio/hugo 2017-06-13 18:47:17 +02:00
pageCache.go hugolib: Implement "related content" 2017-09-06 00:20:02 +02:00
pageCache_test.go hugolib: Implement "related content" 2017-09-06 00:20:02 +02:00
pageGroup.go hugolib: Do not tolower result from Page.GetParam 2017-12-29 08:58:38 +01:00
pageGroup_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pages_related.go hugolib: Fix typo in aquired 2017-09-07 16:21:33 +02:00
pages_related_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pageSort.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pageSort_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pagesPrevNext.go huglib: Add even more missing GoDoc 2016-04-07 16:05:23 +02:00
pagesPrevNext_test.go all: Refactor to nonglobal Viper, i18n etc. 2017-02-17 17:15:26 +01:00
pagination.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
pagination_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
path_separators_test.go hugolib, output: Incorporate suffix and type in layout resolve 2017-03-27 15:43:56 +02:00
permalinker.go hugolib: Add optional outputFormat to Ref/RelRef 2017-04-04 23:09:01 +02:00
permalinks.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
permalinks_test.go all: Refactor to nonglobal Viper, i18n etc. 2017-02-17 17:15:26 +01:00
prune_resources.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
robotstxt_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
rss_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
scratch.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
scratch_test.go all: Refactor to nonglobal Viper, i18n etc. 2017-02-17 17:15:26 +01:00
shortcode.go output: Support templates per site/language 2017-07-04 09:12:44 +02:00
shortcode_test.go Add "target" and "rel" parameters to figure shortcode 2018-02-09 22:27:58 +01:00
shortcodeparser.go Remove the goroutines from the shortcode lexer 2017-12-07 23:08:25 +01:00
shortcodeparser_test.go all: Refactor to nonglobal Viper, i18n etc. 2017-02-17 17:15:26 +01:00
site.go hugolib: Extract date and slug from filename 2018-03-11 18:26:18 +01:00
site_benchmark_test.go Add a GetPage to the site benchmarks 2018-01-24 09:08:26 +01:00
site_output.go Allow partial redefinition of the ouputs config 2018-03-10 16:57:25 +01:00
site_output_test.go Allow partial redefinition of the ouputs config 2018-03-10 16:57:25 +01:00
site_render.go hugolib: Extract the Fast Render Mode logic into a method 2018-01-30 10:49:24 +01:00
site_sections.go hugolib: Avoid scanning entire site to find the home 2018-02-25 10:50:44 +01:00
site_sections_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
site_stats_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
site_test.go hugolib: Remove unused code 2018-01-25 17:14:03 +01:00
site_url_test.go hugolib: Fix paginator URL for sections with URL in front matter 2018-02-26 17:45:51 +01:00
siteJSONEncode_test.go Implement Page bundling and image handling 2017-12-27 18:44:47 +01:00
sitemap.go hugolib: Fix some more Golint warnings 2016-03-23 10:10:28 +01:00
sitemap_test.go all: Update import paths to gohugoio/hugo 2017-06-13 18:42:45 +02:00
taxonomy.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
taxonomy_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
template_engines_test.go Fix broken shortcodes for Ace and Amber 2017-11-18 10:41:31 +01:00
template_test.go hugolib: Add additional test to TestTemplateLookupOrder 2018-02-05 08:38:04 +01:00
testhelpers_test.go resource: Add front matter metadata to Resource 2018-01-17 16:22:33 +01:00
translations.go hugolib: Fix .IsTranslated with identical filenames 2017-11-17 19:46:32 +01:00