Commit graph

226 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 88972b0d5b node to page: Refactor the build process
To make it easier to follow and understand.

Both building and rebuilding now follow a four step flow:

1. Init
2. Process
3. Assemble
4. Render

And now there are only one Build method, used for both builds and rebuilds.

Updates #2297
2016-11-22 09:57:03 +01:00
Albert Nigmatzianov 85a2d81e3c commands, tpl: Get rid of repeating viper accesses
* all: Delete some blank lines
* commands, tpl: Get rid of repeating viper accesses
2016-11-07 00:10:32 +01:00
Albert Nigmatzianov 3a86aba517 commands: Move initialization of flags in separate function
And clean up flag variables.
2016-11-03 11:33:53 +01:00
Bjørn Erik Pedersen e8380e612f Add GitInfo
This commit adds a `GitInfo` object to `Page` if `EnableGitInfo` is set.

It then also sets `Lastmod` for the given `Page` to the author date provided by Git.

The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size.

If you want, you can run without during development and turn it on when deploying to the live server: `hugo --enableGitInfo`.

Fixes #2102
2016-11-01 23:04:12 +01:00
Albert Nigmatzianov f21e2f25c9 all: Unify case of config variable names
All config variables starts with low-case and uses camelCase.

If there is abbreviation at the beginning of the name, the whole
abbreviation will be written in low-case.
If there is abbreviation at the end of the name, the
whole abbreviation will be written in upper-case.
For example, rssURI.
2016-10-24 20:56:00 +02:00
Bjørn Erik Pedersen d0d24b4337 commands: Do not print error on missing unknown dirs
See #2602
2016-10-19 20:08:57 +02:00
Bjørn Erik Pedersen f0af80753c commands: Only watch relevant themes dir
The same behavior as for the root project.

Fixes #2602
2016-10-19 20:00:51 +02:00
Dimitri Merejkowsky 56512e816f Allow to set cache dir in config file 2016-10-09 11:00:36 +02:00
Bjørn Erik Pedersen 1c214fcb7c Add quiet mode
Needed to run benchmarks without the stats getting in the way of the benchmark stats.

Fixes #1218
2016-10-08 18:26:16 +02:00
Bjørn Erik Pedersen 2a4ed1c492 Add hugo env command
Useful for bug reports.

Fixes #2523
2016-10-05 10:20:25 +02:00
Albert f0ac26c944 commands: Fix typos 2016-09-12 11:32:11 +02:00
Bjørn Erik Pedersen c700cdc39c Replace some leftover os.Stat with hugofs.Source 2016-09-11 20:00:38 +02:00
bogem 2294b0226d commands: Simplify err condition 2016-09-11 12:23:09 +02:00
bogem 1e18087356 commands: Delete unused newUserErrorF 2016-09-11 12:23:09 +02:00
Bjørn Erik Pedersen 09ed41be71 Add a global Reset func
So we can do some benchmarking.
2016-09-06 18:32:21 +03:00
Bjørn Erik Pedersen 45c69dd168 Handle error in config loading
See #2309
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen f1e1cdab3f Improve i18n string handling
* Fall back to default language on missing translation file
* Add a i18n-warnings build flag
* If that flag is set, print a parseable and greppable string on missing translation strings

See #2303
2016-09-06 18:32:19 +03:00
Bjørn Erik Pedersen e56ecab157 Multilingual TODO-fixes, take 1
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen d18a8cbe15 Fix livereload in multilingual mode
See #2309
2016-09-06 18:32:18 +03:00
Bjørn Erik Pedersen 596e0e98e4 Make it possible to add a language in server mode
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 7cac19b1e3 cmd: Load config from the common config loader in hugolib
See #2309
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 90de511017 Make taxonomies configurable per language
See #2312
2016-09-06 18:32:17 +03:00
Bjørn Erik Pedersen 708bc78770 Optimize the multilanguage build process
Work In Progress!

This commit makes a rework of the build and rebuild process to better suit a multi-site setup.

This also includes a complete overhaul of the site tests. Previous these were a messy mix that
were testing just small parts of the build chain, some of it testing code-paths not even used in
"real life". Now all tests that depends on a built site follows the same and real production code path.

See #2309
Closes #2211
Closes #477
Closes #1744
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen f023dfd763 Move the Build* methods to HugoSites
See #2309
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 5b9c2a40f1 Move HugoSites to hugolib
It will get more involved in the build process in a minute.

See #2309
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 75dd596e6c Introduce HugoSites type
And a Hugo global variable which contains the site under build.

This is really needed to get some level of control of the "multiple languages" in play.

There are still work related to this scattered around, but that will come.

With this commit, the multilingual feature is starting to work.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen c447b7dd6e Rename MainSites to Sites
Having many *main* sites doesn't make much sense.
2016-09-06 18:32:16 +03:00
Bjørn Erik Pedersen 06d12ab895 Add proper Language and Languages types 2016-09-06 18:32:15 +03:00
Alexandre Bourget ec33732fbe Add multilingual support in Hugo
Implements:
* support to render:
  * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html
  * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html
* gets enabled when `Multilingual:` is specified in config.
* support having language switchers in templates, that know
  where the translated page is (with .Page.Translations)
  (when you're on /en/about/, you can have a "Francais" link pointing to
   /fr/a-propos/)
  * all translations are in the `.Page.Translations` map, including the current one.
* easily tweak themes to support Multilingual mode
* renders in a single swift, no need for two config files.

Adds a couple of variables useful for multilingual sites

Adds documentation (content/multilingual.md)

Added language prefixing for all URL generation/permalinking see in the
code base.

Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick.
* Adds "i18n" and "T" template functions..
2016-09-06 18:32:15 +03:00
Bjørn Erik Pedersen 97c37732b4 Add a global Reset func
So we can do some benchmarking.
2016-08-16 12:50:26 +02:00
Kishin Yagami 661c9787ea commands: Suppress 'missing static' error
Fixes #2311
2016-08-14 00:35:43 +02:00
Bjørn Erik Pedersen 4ddd5361c1 Use the Afero source fs where relevant
Fixes #2319
2016-07-30 15:37:03 +02:00
Pedro Melo 3e1b579c17 Be less aggressive with CHMOD filesystem events
On 4679fbee41, rebuild was disabled on
CHMOD filesystem events, but the code is overly aggressive.

In some situations, specially with older Mac's (using a Late 2008
Macbook), the events we receive might be aggregated. On my
particular laptop, I get this events:

    INFO: 2016/07/26 18:08:51 hugo.go:737: Received System Events: ["<path>": WRITE|CHMOD]

These events are ignored because the code only checks for Chmod. This
commit fixes this by checking that the event is also not a Write or Create.

Related to #1587.
2016-07-26 22:18:15 +02:00
Alexandre Bourget 32d82a4496 Ignore emacs temp files 2016-07-11 02:01:45 +02:00
Vincent Batoufflet b8af06f26a Make auto-date disabled by default
Fixes #2244
Closes #2260
2016-07-08 14:43:10 +02:00
Bjørn Erik Pedersen b581bbd856 Make config flag global
Fixes #2261
2016-07-07 18:06:48 +02:00
Hanchen Wang 51f7cd9bde commands: Add buildExpired flag 2016-06-14 15:45:26 +02:00
Steve Francia d1cf262b74 Ignore __jb_tmp___ files created by IntelliJ 2016-06-02 23:47:01 +02:00
Steve Francia f8e4a0608c Annotate temp files that Hugo ignores 2016-06-02 23:47:01 +02:00
Bjørn Erik Pedersen b5030782ae Ignore Byword temp files
Fixes #2126
2016-05-06 20:30:03 +02:00
Anthony Fok 9ddf52021b Update import path of fsnotify
Rename "gopkg.in/fsnotify.v1" to "github.com/fsnotify/fsnotify"
per upstream recommendation.

See https://github.com/fsnotify/fsnotify/issues/108 for rationale.
2016-04-20 22:28:26 +08:00
Bjørn Erik Pedersen b7fd410245 commands: Support config from ENV
So

```bash
env HUGO_TITLE="Some Title" hugo server
```

Will change the `title`.

Fixes #2090
2016-04-18 18:45:37 +02:00
Robert Basic 24cb0d1f58 tpl: Do not write to cache when ignoring cache
Fixes #2067
Closes #2069
2016-04-14 10:48:26 +02:00
digitalcraftsman b7efbdc12f hugolib: Add option to disable rendering of 404 page
Fixes #1889
Closes #2037
2016-04-09 20:25:59 +02:00
Bjørn Erik Pedersen 54750b0780 Do not create robots.txt by default
Meny people, including me, have a custom robots.txt in static.

Also remove that option from the command line; it doesn't feel
important enough.

Fixes ##2049
2016-04-05 22:20:39 +02:00
Philipp Oppermann 43b5dfabb5 Disable syntax guessing for PygmentsCodeFences by default
This disables highlighting for fenced code blocks without explicitly specified language. It also introduces a new `PygmentsCodeFencesGuessSyntax` config option (defaulting to false).

To enable syntax guessing again, add the following to your config file: `PygmentsCodeFencesGuessSyntax = true`

This is a breaking change.
2016-04-04 22:19:36 +02:00
Bjørn Erik Pedersen 4f66f790b1 Add readFile template func
This also includes a refactor of the hugofs package and its usage.

The motivation for that is:

The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...)

Fixes #1551
2016-03-31 21:24:18 +02:00
Bjørn Erik Pedersen a7953e25bb commands: Apply Golint rules to hugo.go 2016-03-24 14:24:22 +01:00
Bjørn Erik Pedersen e5aa477491 Add support for symbolic links for content, layout, static, theme
Note: This is for the content roots only, but that should satisfy most needs.

Fixes #1855
2016-03-21 19:13:29 -04:00
John Ku 0ab4162413 Ability to config layout and content dir via cli
fixes spf13/hugo#1598
2016-03-11 23:42:27 +01:00