aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-12-29 09:37:37 +0100
committerBjørn Erik Pedersen <[email protected]>2017-12-29 09:37:37 +0100
commit72903be587e9c4e3644f60b11e26238ec03da2db (patch)
treec59cc06465771502f2f7669a3e593f567af18b2c
parent1c114d539b0755724443fe28c90b12fe2a19085a (diff)
downloadhugo-72903be587e9c4e3644f60b11e26238ec03da2db.tar.gz
hugo-72903be587e9c4e3644f60b11e26238ec03da2db.zip
commands: Make sure all language homes are always re-rendered in fast render mode
Fixes #4125
-rw-r--r--commands/hugo.go14
-rw-r--r--helpers/pathspec.go23
-rw-r--r--helpers/url.go17
3 files changed, 44 insertions, 10 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 200a5e1c3..743c5a267 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -940,9 +940,17 @@ func (c *commandeer) rebuildSites(events []fsnotify.Event) error {
visited := c.visitedURLs.PeekAllSet()
doLiveReload := !buildWatch && !c.Cfg.GetBool("disableLiveReload")
if doLiveReload && !c.Cfg.GetBool("disableFastRender") {
- home := c.pathSpec.PrependBasePath("/")
- // Make sure we always render the home page
- visited[home] = true
+
+ // Make sure we always render the home pages
+ for _, l := range c.languages {
+ langPath := c.PathSpec().GetLangSubDir(l.Lang)
+ if langPath != "" {
+ langPath = langPath + "/"
+ }
+ home := c.pathSpec.PrependBasePath("/" + langPath)
+ visited[home] = true
+ }
+
}
return Hugo.Build(hugolib.BuildCfg{RecentlyVisited: visited}, events...)
}
diff --git a/helpers/pathspec.go b/helpers/pathspec.go
index d5a2c92e8..281203712 100644
--- a/helpers/pathspec.go
+++ b/helpers/pathspec.go
@@ -31,8 +31,8 @@ type PathSpec struct {
uglyURLs bool
canonifyURLs bool
- language *Language
- //StatsCounter *siteSta
+ language *Language
+ languages Languages
// pagination path handling
paginatePath string
@@ -85,9 +85,20 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
staticDirs = append(staticDirs, getStringOrStringSlice(cfg, "staticDir", i)...)
}
- var lang string
+ var (
+ lang string
+ language *Language
+ languages Languages
+ )
+
if l, ok := cfg.(*Language); ok {
+ language = l
lang = l.Lang
+
+ }
+
+ if l, ok := cfg.Get("languagesSorted").(Languages); ok {
+ languages = l
}
ps := &PathSpec{
@@ -98,6 +109,8 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
uglyURLs: cfg.GetBool("uglyURLs"),
canonifyURLs: cfg.GetBool("canonifyURLs"),
multilingual: cfg.GetBool("multilingual"),
+ language: language,
+ languages: languages,
defaultContentLanguageInSubdir: cfg.GetBool("defaultContentLanguageInSubdir"),
defaultContentLanguage: cfg.GetString("defaultContentLanguage"),
paginatePath: cfg.GetString("paginatePath"),
@@ -119,10 +132,6 @@ func NewPathSpec(fs *hugofs.Fs, cfg config.Provider) (*PathSpec, error) {
ps.PublishDir = publishDir
- if language, ok := cfg.(*Language); ok {
- ps.language = language
- }
-
return ps, nil
}
diff --git a/helpers/url.go b/helpers/url.go
index 9c1a643cc..8faefeefa 100644
--- a/helpers/url.go
+++ b/helpers/url.go
@@ -215,6 +215,23 @@ func (p *PathSpec) getLanguagePrefix() string {
return currentLang
}
+// GetLangSubDir returns the given language's subdir if needed.
+func (p *PathSpec) GetLangSubDir(lang string) string {
+ if !p.multilingual {
+ return ""
+ }
+
+ if p.languages.IsMultihost() {
+ return ""
+ }
+
+ if lang == "" || (lang == p.defaultContentLanguage && !p.defaultContentLanguageInSubdir) {
+ return ""
+ }
+
+ return lang
+}
+
// IsAbsURL determines whether the given path points to an absolute URL.
func IsAbsURL(path string) bool {
url, err := url.Parse(path)