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...)
}
uglyURLs bool
canonifyURLs bool
- language *Language
- //StatsCounter *siteSta
+ language *Language
+ languages Languages
// pagination path handling
paginatePath string
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{
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"),
ps.PublishDir = publishDir
- if language, ok := cfg.(*Language); ok {
- ps.language = language
- }
-
return ps, nil
}
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)