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.
This commit is contained in:
parent
d9f54a13c1
commit
f21e2f25c9
67 changed files with 469 additions and 469 deletions
|
@ -134,7 +134,7 @@ func convertContents(mark rune) (err error) {
|
||||||
metadata = newmetadata
|
metadata = newmetadata
|
||||||
}
|
}
|
||||||
|
|
||||||
page.SetDir(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), file.Dir()))
|
page.SetDir(filepath.Join(helpers.AbsPathify(viper.GetString("contentDir")), file.Dir()))
|
||||||
page.SetSourceContent(psr.Content())
|
page.SetSourceContent(psr.Content())
|
||||||
if err = page.SetSourceMetaData(metadata, mark); err != nil {
|
if err = page.SetSourceMetaData(metadata, mark); err != nil {
|
||||||
jww.ERROR.Printf("Failed to set source metadata for file %q: %s. For more info see For more info see https://github.com/spf13/hugo/issues/2458", page.FullFilePath(), err)
|
jww.ERROR.Printf("Failed to set source metadata for file %q: %s. For more info see For more info see https://github.com/spf13/hugo/issues/2458", page.FullFilePath(), err)
|
||||||
|
|
106
commands/hugo.go
106
commands/hugo.go
|
@ -117,7 +117,7 @@ Complete documentation is available at http://gohugo.io/.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
if buildWatch {
|
if buildWatch {
|
||||||
viper.Set("DisableLiveReload", true)
|
viper.Set("disableLiveReload", true)
|
||||||
watchConfig()
|
watchConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,55 +284,55 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) {
|
for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) {
|
||||||
|
|
||||||
if flagChanged(cmdV.PersistentFlags(), "verbose") {
|
if flagChanged(cmdV.PersistentFlags(), "verbose") {
|
||||||
viper.Set("Verbose", verbose)
|
viper.Set("verbose", verbose)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.PersistentFlags(), "logFile") {
|
if flagChanged(cmdV.PersistentFlags(), "logFile") {
|
||||||
viper.Set("LogFile", logFile)
|
viper.Set("logFile", logFile)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "cleanDestinationDir") {
|
if flagChanged(cmdV.Flags(), "cleanDestinationDir") {
|
||||||
viper.Set("cleanDestinationDir", cleanDestination)
|
viper.Set("cleanDestinationDir", cleanDestination)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "buildDrafts") {
|
if flagChanged(cmdV.Flags(), "buildDrafts") {
|
||||||
viper.Set("BuildDrafts", draft)
|
viper.Set("buildDrafts", draft)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "buildFuture") {
|
if flagChanged(cmdV.Flags(), "buildFuture") {
|
||||||
viper.Set("BuildFuture", future)
|
viper.Set("buildFuture", future)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "buildExpired") {
|
if flagChanged(cmdV.Flags(), "buildExpired") {
|
||||||
viper.Set("BuildExpired", expired)
|
viper.Set("buildExpired", expired)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "uglyURLs") {
|
if flagChanged(cmdV.Flags(), "uglyURLs") {
|
||||||
viper.Set("UglyURLs", uglyURLs)
|
viper.Set("uglyURLs", uglyURLs)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "canonifyURLs") {
|
if flagChanged(cmdV.Flags(), "canonifyURLs") {
|
||||||
viper.Set("CanonifyURLs", canonifyURLs)
|
viper.Set("canonifyURLs", canonifyURLs)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "disable404") {
|
if flagChanged(cmdV.Flags(), "disable404") {
|
||||||
viper.Set("Disable404", disable404)
|
viper.Set("disable404", disable404)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "disableRSS") {
|
if flagChanged(cmdV.Flags(), "disableRSS") {
|
||||||
viper.Set("DisableRSS", disableRSS)
|
viper.Set("disableRSS", disableRSS)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "disableSitemap") {
|
if flagChanged(cmdV.Flags(), "disableSitemap") {
|
||||||
viper.Set("DisableSitemap", disableSitemap)
|
viper.Set("disableSitemap", disableSitemap)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "enableRobotsTXT") {
|
if flagChanged(cmdV.Flags(), "enableRobotsTXT") {
|
||||||
viper.Set("EnableRobotsTXT", enableRobotsTXT)
|
viper.Set("enableRobotsTXT", enableRobotsTXT)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
|
if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
|
||||||
viper.Set("PluralizeListTitles", pluralizeListTitles)
|
viper.Set("pluralizeListTitles", pluralizeListTitles)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") {
|
if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") {
|
||||||
viper.Set("PreserveTaxonomyNames", preserveTaxonomyNames)
|
viper.Set("preserveTaxonomyNames", preserveTaxonomyNames)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "ignoreCache") {
|
if flagChanged(cmdV.Flags(), "ignoreCache") {
|
||||||
viper.Set("IgnoreCache", ignoreCache)
|
viper.Set("ignoreCache", ignoreCache)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "forceSyncStatic") {
|
if flagChanged(cmdV.Flags(), "forceSyncStatic") {
|
||||||
viper.Set("ForceSyncStatic", forceSync)
|
viper.Set("forceSyncStatic", forceSync)
|
||||||
}
|
}
|
||||||
if flagChanged(cmdV.Flags(), "noTimes") {
|
if flagChanged(cmdV.Flags(), "noTimes") {
|
||||||
viper.Set("NoTimes", noTimes)
|
viper.Set("noTimes", noTimes)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -341,10 +341,10 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
if !strings.HasSuffix(baseURL, "/") {
|
if !strings.HasSuffix(baseURL, "/") {
|
||||||
baseURL = baseURL + "/"
|
baseURL = baseURL + "/"
|
||||||
}
|
}
|
||||||
viper.Set("BaseURL", baseURL)
|
viper.Set("baseURL", baseURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viper.GetBool("RelativeURLs") && viper.GetString("BaseURL") == "" {
|
if !viper.GetBool("relativeURLs") && viper.GetString("baseURL") == "" {
|
||||||
jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
|
jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,27 +353,27 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if destination != "" {
|
if destination != "" {
|
||||||
viper.Set("PublishDir", destination)
|
viper.Set("publishDir", destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dir string
|
||||||
if source != "" {
|
if source != "" {
|
||||||
dir, _ := filepath.Abs(source)
|
dir, _ = filepath.Abs(source)
|
||||||
viper.Set("WorkingDir", dir)
|
|
||||||
} else {
|
} else {
|
||||||
dir, _ := os.Getwd()
|
dir, _ = os.Getwd()
|
||||||
viper.Set("WorkingDir", dir)
|
|
||||||
}
|
}
|
||||||
|
viper.Set("workingDir", dir)
|
||||||
|
|
||||||
if contentDir != "" {
|
if contentDir != "" {
|
||||||
viper.Set("ContentDir", contentDir)
|
viper.Set("contentDir", contentDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if layoutDir != "" {
|
if layoutDir != "" {
|
||||||
viper.Set("LayoutDir", layoutDir)
|
viper.Set("layoutDir", layoutDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cacheDir != "" {
|
if cacheDir != "" {
|
||||||
viper.Set("CacheDir", cacheDir)
|
viper.Set("cacheDir", cacheDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheDir = viper.GetString("cacheDir")
|
cacheDir = viper.GetString("cacheDir")
|
||||||
|
@ -386,14 +386,14 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
|
||||||
if isDir == false {
|
if isDir == false {
|
||||||
mkdir(cacheDir)
|
mkdir(cacheDir)
|
||||||
}
|
}
|
||||||
viper.Set("CacheDir", cacheDir)
|
viper.Set("cacheDir", cacheDir)
|
||||||
} else {
|
} else {
|
||||||
viper.Set("CacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
|
viper.Set("cacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if verboseLog || logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
|
if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") {
|
||||||
if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
|
if viper.IsSet("logFile") && viper.GetString("logFile") != "" {
|
||||||
jww.SetLogFile(viper.GetString("LogFile"))
|
jww.SetLogFile(viper.GetString("logFile"))
|
||||||
} else {
|
} else {
|
||||||
jww.UseTempLogFile("hugo")
|
jww.UseTempLogFile("hugo")
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ func watchConfig() {
|
||||||
fmt.Println("Config file changed:", e.Name)
|
fmt.Println("Config file changed:", e.Name)
|
||||||
// Force a full rebuild
|
// Force a full rebuild
|
||||||
utils.CheckErr(reCreateAndbuildSites(true))
|
utils.CheckErr(reCreateAndbuildSites(true))
|
||||||
if !viper.GetBool("DisableLiveReload") {
|
if !viper.GetBool("disableLiveReload") {
|
||||||
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
||||||
livereload.ForceRefresh()
|
livereload.ForceRefresh()
|
||||||
}
|
}
|
||||||
|
@ -463,11 +463,11 @@ func build(watches ...bool) error {
|
||||||
if renderToMemory {
|
if renderToMemory {
|
||||||
hugofs.SetDestination(new(afero.MemMapFs))
|
hugofs.SetDestination(new(afero.MemMapFs))
|
||||||
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
||||||
viper.Set("PublishDir", "/")
|
viper.Set("publishDir", "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := copyStatic(); err != nil {
|
if err := copyStatic(); err != nil {
|
||||||
return fmt.Errorf("Error copying static files to %s: %s", helpers.AbsPathify(viper.GetString("PublishDir")), err)
|
return fmt.Errorf("Error copying static files to %s: %s", helpers.AbsPathify(viper.GetString("publishDir")), err)
|
||||||
}
|
}
|
||||||
watch := false
|
watch := false
|
||||||
if len(watches) > 0 && watches[0] {
|
if len(watches) > 0 && watches[0] {
|
||||||
|
@ -478,7 +478,7 @@ func build(watches ...bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if buildWatch {
|
if buildWatch {
|
||||||
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("ContentDir")))
|
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("contentDir")))
|
||||||
jww.FEEDBACK.Println("Press Ctrl+C to stop")
|
jww.FEEDBACK.Println("Press Ctrl+C to stop")
|
||||||
utils.CheckErr(NewWatcher(0))
|
utils.CheckErr(NewWatcher(0))
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ func getStaticSourceFs() afero.Fs {
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyStatic() error {
|
func copyStatic() error {
|
||||||
publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + helpers.FilePathSeparator
|
publishDir := helpers.AbsPathify(viper.GetString("publishDir")) + helpers.FilePathSeparator
|
||||||
|
|
||||||
// If root, remove the second '/'
|
// If root, remove the second '/'
|
||||||
if publishDir == "//" {
|
if publishDir == "//" {
|
||||||
|
@ -567,10 +567,10 @@ func copyStatic() error {
|
||||||
// getDirList provides NewWatcher() with a list of directories to watch for changes.
|
// getDirList provides NewWatcher() with a list of directories to watch for changes.
|
||||||
func getDirList() []string {
|
func getDirList() []string {
|
||||||
var a []string
|
var a []string
|
||||||
dataDir := helpers.AbsPathify(viper.GetString("DataDir"))
|
dataDir := helpers.AbsPathify(viper.GetString("dataDir"))
|
||||||
i18nDir := helpers.AbsPathify(viper.GetString("I18nDir"))
|
i18nDir := helpers.AbsPathify(viper.GetString("i18nDir"))
|
||||||
layoutDir := helpers.AbsPathify(viper.GetString("LayoutDir"))
|
layoutDir := helpers.AbsPathify(viper.GetString("layoutDir"))
|
||||||
staticDir := helpers.AbsPathify(viper.GetString("StaticDir"))
|
staticDir := helpers.AbsPathify(viper.GetString("staticDir"))
|
||||||
var themesDir string
|
var themesDir string
|
||||||
|
|
||||||
if helpers.ThemeSet() {
|
if helpers.ThemeSet() {
|
||||||
|
@ -580,22 +580,22 @@ func getDirList() []string {
|
||||||
walker := func(path string, fi os.FileInfo, err error) error {
|
walker := func(path string, fi os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if path == dataDir && os.IsNotExist(err) {
|
if path == dataDir && os.IsNotExist(err) {
|
||||||
jww.WARN.Println("Skip DataDir:", err)
|
jww.WARN.Println("Skip dataDir:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == i18nDir && os.IsNotExist(err) {
|
if path == i18nDir && os.IsNotExist(err) {
|
||||||
jww.WARN.Println("Skip I18nDir:", err)
|
jww.WARN.Println("Skip i18nDir:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == layoutDir && os.IsNotExist(err) {
|
if path == layoutDir && os.IsNotExist(err) {
|
||||||
jww.WARN.Println("Skip LayoutDir:", err)
|
jww.WARN.Println("Skip layoutDir:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == staticDir && os.IsNotExist(err) {
|
if path == staticDir && os.IsNotExist(err) {
|
||||||
jww.WARN.Println("Skip StaticDir:", err)
|
jww.WARN.Println("Skip staticDir:", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,9 +636,9 @@ func getDirList() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
helpers.SymbolicWalk(hugofs.Source(), dataDir, walker)
|
helpers.SymbolicWalk(hugofs.Source(), dataDir, walker)
|
||||||
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("ContentDir")), walker)
|
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("contentDir")), walker)
|
||||||
helpers.SymbolicWalk(hugofs.Source(), i18nDir, walker)
|
helpers.SymbolicWalk(hugofs.Source(), i18nDir, walker)
|
||||||
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
|
helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("layoutDir")), walker)
|
||||||
|
|
||||||
helpers.SymbolicWalk(hugofs.Source(), staticDir, walker)
|
helpers.SymbolicWalk(hugofs.Source(), staticDir, walker)
|
||||||
if helpers.ThemeSet() {
|
if helpers.ThemeSet() {
|
||||||
|
@ -801,7 +801,7 @@ func NewWatcher(port int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(staticEvents) > 0 {
|
if len(staticEvents) > 0 {
|
||||||
publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + helpers.FilePathSeparator
|
publishDir := helpers.AbsPathify(viper.GetString("publishDir")) + helpers.FilePathSeparator
|
||||||
|
|
||||||
// If root, remove the second '/'
|
// If root, remove the second '/'
|
||||||
if publishDir == "//" {
|
if publishDir == "//" {
|
||||||
|
@ -812,11 +812,11 @@ func NewWatcher(port int) error {
|
||||||
const layout = "2006-01-02 15:04 -0700"
|
const layout = "2006-01-02 15:04 -0700"
|
||||||
fmt.Println(time.Now().Format(layout))
|
fmt.Println(time.Now().Format(layout))
|
||||||
|
|
||||||
if viper.GetBool("ForceSyncStatic") {
|
if viper.GetBool("forceSyncStatic") {
|
||||||
jww.FEEDBACK.Printf("Syncing all static files\n")
|
jww.FEEDBACK.Printf("Syncing all static files\n")
|
||||||
err := copyStatic()
|
err := copyStatic()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.StopOnErr(err, fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))
|
utils.StopOnErr(err, fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("publishDir"))))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
staticSourceFs := getStaticSourceFs()
|
staticSourceFs := getStaticSourceFs()
|
||||||
|
@ -896,7 +896,7 @@ func NewWatcher(port int) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !buildWatch && !viper.GetBool("DisableLiveReload") {
|
if !buildWatch && !viper.GetBool("disableLiveReload") {
|
||||||
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
||||||
|
|
||||||
// force refresh when more than one file
|
// force refresh when more than one file
|
||||||
|
@ -919,7 +919,7 @@ func NewWatcher(port int) error {
|
||||||
|
|
||||||
rebuildSites(dynamicEvents)
|
rebuildSites(dynamicEvents)
|
||||||
|
|
||||||
if !buildWatch && !viper.GetBool("DisableLiveReload") {
|
if !buildWatch && !viper.GetBool("disableLiveReload") {
|
||||||
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
||||||
livereload.ForceRefresh()
|
livereload.ForceRefresh()
|
||||||
}
|
}
|
||||||
|
@ -933,7 +933,7 @@ func NewWatcher(port int) error {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if port > 0 {
|
if port > 0 {
|
||||||
if !viper.GetBool("DisableLiveReload") {
|
if !viper.GetBool("disableLiveReload") {
|
||||||
livereload.Initialize()
|
livereload.Initialize()
|
||||||
http.HandleFunc("/livereload.js", livereload.ServeJS)
|
http.HandleFunc("/livereload.js", livereload.ServeJS)
|
||||||
http.HandleFunc("/livereload", livereload.Handler)
|
http.HandleFunc("/livereload", livereload.Handler)
|
||||||
|
|
|
@ -221,7 +221,7 @@ func loadJekyllConfig(jekyllRoot string) map[string]interface{} {
|
||||||
|
|
||||||
func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]interface{}) (err error) {
|
func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]interface{}) (err error) {
|
||||||
title := "My New Hugo Site"
|
title := "My New Hugo Site"
|
||||||
baseurl := "http://example.org/"
|
baseURL := "http://example.org/"
|
||||||
|
|
||||||
for key, value := range jekyllConfig {
|
for key, value := range jekyllConfig {
|
||||||
lowerKey := strings.ToLower(key)
|
lowerKey := strings.ToLower(key)
|
||||||
|
@ -234,13 +234,13 @@ func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]
|
||||||
|
|
||||||
case "url":
|
case "url":
|
||||||
if str, ok := value.(string); ok {
|
if str, ok := value.(string); ok {
|
||||||
baseurl = str
|
baseURL = str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
in := map[string]interface{}{
|
in := map[string]interface{}{
|
||||||
"baseurl": baseurl,
|
"baseURL": baseURL,
|
||||||
"title": title,
|
"title": title,
|
||||||
"languageCode": "en-us",
|
"languageCode": "en-us",
|
||||||
"disablePathToLower": true,
|
"disablePathToLower": true,
|
||||||
|
|
|
@ -49,7 +49,7 @@ var listDraftsCmd = &cobra.Command{
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("BuildDrafts", true)
|
viper.Set("buildDrafts", true)
|
||||||
|
|
||||||
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ posted in the future.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("BuildFuture", true)
|
viper.Set("buildFuture", true)
|
||||||
|
|
||||||
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ expired.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("BuildExpired", true)
|
viper.Set("buildExpired", true)
|
||||||
|
|
||||||
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
sites, err := hugolib.NewHugoSitesFromConfiguration()
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,11 @@ func NewContent(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if flagChanged(cmd.Flags(), "format") {
|
if flagChanged(cmd.Flags(), "format") {
|
||||||
viper.Set("MetaDataFormat", configFormat)
|
viper.Set("metaDataFormat", configFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
if flagChanged(cmd.Flags(), "editor") {
|
if flagChanged(cmd.Flags(), "editor") {
|
||||||
viper.Set("NewContentEditor", contentEditor)
|
viper.Set("newContentEditor", contentEditor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
|
|
|
@ -90,7 +90,7 @@ func init() {
|
||||||
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
|
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port on which the server will listen")
|
||||||
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
|
serverCmd.Flags().StringVarP(&serverInterface, "bind", "", "127.0.0.1", "interface to which the server will bind")
|
||||||
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
|
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", true, "watch filesystem for changes and recreate as needed")
|
||||||
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseurl")
|
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseURL")
|
||||||
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
|
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
|
||||||
serverCmd.Flags().BoolVar(&renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)")
|
serverCmd.Flags().BoolVar(&renderToDisk, "renderToDisk", false, "render to Destination path (default is render to memory & serve from there)")
|
||||||
serverCmd.Flags().String("memstats", "", "log memory usage to this file")
|
serverCmd.Flags().String("memstats", "", "log memory usage to this file")
|
||||||
|
@ -109,11 +109,11 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if flagChanged(cmd.Flags(), "disableLiveReload") {
|
if flagChanged(cmd.Flags(), "disableLiveReload") {
|
||||||
viper.Set("DisableLiveReload", disableLiveReload)
|
viper.Set("disableLiveReload", disableLiveReload)
|
||||||
}
|
}
|
||||||
|
|
||||||
if serverWatch {
|
if serverWatch {
|
||||||
viper.Set("Watch", true)
|
viper.Set("watch", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("watch") {
|
if viper.GetBool("watch") {
|
||||||
|
@ -139,11 +139,11 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
viper.Set("port", serverPort)
|
viper.Set("port", serverPort)
|
||||||
|
|
||||||
BaseURL, err := fixURL(baseURL)
|
baseURL, err = fixURL(baseURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
viper.Set("BaseURL", BaseURL)
|
viper.Set("baseURL", baseURL)
|
||||||
|
|
||||||
if err := memStats(); err != nil {
|
if err := memStats(); err != nil {
|
||||||
jww.ERROR.Println("memstats error:", err)
|
jww.ERROR.Println("memstats error:", err)
|
||||||
|
@ -158,7 +158,7 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
if !renderToDisk {
|
if !renderToDisk {
|
||||||
hugofs.SetDestination(new(afero.MemMapFs))
|
hugofs.SetDestination(new(afero.MemMapFs))
|
||||||
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
||||||
viper.Set("PublishDir", "/")
|
viper.Set("publishDir", "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := build(serverWatch); err != nil {
|
if err := build(serverWatch); err != nil {
|
||||||
|
@ -168,7 +168,7 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
// Watch runs its own server as part of the routine
|
// Watch runs its own server as part of the routine
|
||||||
if serverWatch {
|
if serverWatch {
|
||||||
watchDirs := getDirList()
|
watchDirs := getDirList()
|
||||||
baseWatchDir := viper.GetString("WorkingDir")
|
baseWatchDir := viper.GetString("workingDir")
|
||||||
for i, dir := range watchDirs {
|
for i, dir := range watchDirs {
|
||||||
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
|
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
|
||||||
}
|
}
|
||||||
|
@ -190,19 +190,19 @@ func server(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
func serve(port int) {
|
func serve(port int) {
|
||||||
if renderToDisk {
|
if renderToDisk {
|
||||||
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir")))
|
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("publishDir")))
|
||||||
} else {
|
} else {
|
||||||
jww.FEEDBACK.Println("Serving pages from memory")
|
jww.FEEDBACK.Println("Serving pages from memory")
|
||||||
}
|
}
|
||||||
|
|
||||||
httpFs := afero.NewHttpFs(hugofs.Destination())
|
httpFs := afero.NewHttpFs(hugofs.Destination())
|
||||||
fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("PublishDir")))}
|
fs := filesOnlyFs{httpFs.Dir(helpers.AbsPathify(viper.GetString("publishDir")))}
|
||||||
fileserver := http.FileServer(fs)
|
fileserver := http.FileServer(fs)
|
||||||
|
|
||||||
// We're only interested in the path
|
// We're only interested in the path
|
||||||
u, err := url.Parse(viper.GetString("BaseURL"))
|
u, err := url.Parse(viper.GetString("baseURL"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jww.ERROR.Fatalf("Invalid BaseURL: %s", err)
|
jww.ERROR.Fatalf("Invalid baseURL: %s", err)
|
||||||
}
|
}
|
||||||
if u.Path == "" || u.Path == "/" {
|
if u.Path == "" || u.Path == "/" {
|
||||||
http.Handle("/", fileserver)
|
http.Handle("/", fileserver)
|
||||||
|
@ -221,12 +221,12 @@ func serve(port int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixURL massages the BaseURL into a form needed for serving
|
// fixURL massages the baseURL into a form needed for serving
|
||||||
// all pages correctly.
|
// all pages correctly.
|
||||||
func fixURL(s string) (string, error) {
|
func fixURL(s string) (string, error) {
|
||||||
useLocalhost := false
|
useLocalhost := false
|
||||||
if s == "" {
|
if s == "" {
|
||||||
s = viper.GetString("BaseURL")
|
s = viper.GetString("baseURL")
|
||||||
useLocalhost = true
|
useLocalhost = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ func fixURL(s string) (string, error) {
|
||||||
if strings.Contains(u.Host, ":") {
|
if strings.Contains(u.Host, ":") {
|
||||||
u.Host, _, err = net.SplitHostPort(u.Host)
|
u.Host, _, err = net.SplitHostPort(u.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Failed to split BaseURL hostpost: %s", err)
|
return "", fmt.Errorf("Failed to split baseURL hostpost: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
u.Host += fmt.Sprintf(":%d", serverPort)
|
u.Host += fmt.Sprintf(":%d", serverPort)
|
||||||
|
|
|
@ -46,7 +46,7 @@ func TestFixURL(t *testing.T) {
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
baseURL = test.CLIBaseURL
|
baseURL = test.CLIBaseURL
|
||||||
viper.Set("BaseURL", test.CfgBaseURL)
|
viper.Set("baseURL", test.CfgBaseURL)
|
||||||
serverAppend = test.AppendPort
|
serverAppend = test.AppendPort
|
||||||
serverPort = test.Port
|
serverPort = test.Port
|
||||||
result, err := fixURL(baseURL)
|
result, err := fixURL(baseURL)
|
||||||
|
|
|
@ -67,7 +67,7 @@ func NewContent(fs afero.Fs, kind, name string) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = page.SetSourceMetaData(metadata, parser.FormatToLeadRune(viper.GetString("MetaDataFormat"))); err != nil {
|
if err = page.SetSourceMetaData(metadata, parser.FormatToLeadRune(viper.GetString("metaDataFormat"))); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ func NewContent(fs afero.Fs, kind, name string) (err error) {
|
||||||
}
|
}
|
||||||
jww.FEEDBACK.Println(helpers.AbsPathify(filepath.Join(viper.GetString("contentDir"), name)), "created")
|
jww.FEEDBACK.Println(helpers.AbsPathify(filepath.Join(viper.GetString("contentDir"), name)), "created")
|
||||||
|
|
||||||
editor := viper.GetString("NewContentEditor")
|
editor := viper.GetString("newContentEditor")
|
||||||
|
|
||||||
if editor != "" {
|
if editor != "" {
|
||||||
jww.FEEDBACK.Printf("Editing %s with %q ...\n", name, editor)
|
jww.FEEDBACK.Printf("Editing %s with %q ...\n", name, editor)
|
||||||
|
@ -137,7 +137,7 @@ func createMetadata(archetype parser.Page, name string) (map[string]interface{},
|
||||||
metadata["title"] = helpers.MakeTitle(helpers.Filename(name))
|
metadata["title"] = helpers.MakeTitle(helpers.Filename(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if x := parser.FormatSanitize(viper.GetString("MetaDataFormat")); x == "json" || x == "yaml" || x == "toml" {
|
if x := parser.FormatSanitize(viper.GetString("metaDataFormat")); x == "json" || x == "yaml" || x == "toml" {
|
||||||
metadata["date"] = time.Now().Format(time.RFC3339)
|
metadata["date"] = time.Now().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestNewContent(t *testing.T) {
|
||||||
|
|
||||||
func initViper() {
|
func initViper() {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
viper.Set("MetaDataFormat", "toml")
|
viper.Set("metaDataFormat", "toml")
|
||||||
viper.Set("archetypeDir", filepath.Join(os.TempDir(), "archetypes"))
|
viper.Set("archetypeDir", filepath.Join(os.TempDir(), "archetypes"))
|
||||||
viper.Set("contentDir", filepath.Join(os.TempDir(), "content"))
|
viper.Set("contentDir", filepath.Join(os.TempDir(), "content"))
|
||||||
viper.Set("themesDir", filepath.Join(os.TempDir(), "themes"))
|
viper.Set("themesDir", filepath.Join(os.TempDir(), "themes"))
|
||||||
|
|
|
@ -14,7 +14,7 @@ Hugo supports multiple languages side-by-side (added in `Hugo 0.17`). Define the
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
DefaultContentLanguage = "en"
|
defaultContentLanguage = "en"
|
||||||
|
|
||||||
Languages:
|
Languages:
|
||||||
en:
|
en:
|
||||||
|
@ -38,7 +38,7 @@ value for that key (like `copyright` for the English (`en`) language in this exa
|
||||||
With the config above, all content, sitemap, RSS feeds, paginations
|
With the config above, all content, sitemap, RSS feeds, paginations
|
||||||
and taxonomy pages will be rendered below `/` in English (your default content language), and below `/fr` in French.
|
and taxonomy pages will be rendered below `/` in English (your default content language), and below `/fr` in French.
|
||||||
|
|
||||||
If you want all of the languages to be put below their respective language code, enable `DefaultContentLanguageInSubdir: true` in your configuration.
|
If you want all of the languages to be put below their respective language code, enable `defaultContentLanguageInSubdir: true` in your configuration.
|
||||||
|
|
||||||
Only the obvious non-global options can be overridden per language. Examples of global options are `BaseURL`, `BuildDrafts`, etc.
|
Only the obvious non-global options can be overridden per language. Examples of global options are `BaseURL`, `BuildDrafts`, etc.
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ You can also have:
|
||||||
1. `/content/about.md`
|
1. `/content/about.md`
|
||||||
2. `/content/about.fr.md`
|
2. `/content/about.fr.md`
|
||||||
|
|
||||||
In which case the config variable `DefaultContentLanguage` will be used to affect the default language `about.md`. This way, you can
|
In which case the config variable `defaultContentLanguage` will be used to affect the default language `about.md`. This way, you can
|
||||||
slowly start to translate your current content without having to rename everything.
|
slowly start to translate your current content without having to rename everything.
|
||||||
|
|
||||||
If left unspecified, the value for `DefaultContentLanguage` defaults to `en`.
|
If left unspecified, the value for `defaultContentLanguage` defaults to `en`.
|
||||||
|
|
||||||
By having the same _base file name_, the content pieces are linked together as translated pieces.
|
By having the same _base file name_, the content pieces are linked together as translated pieces.
|
||||||
|
|
||||||
|
@ -159,14 +159,12 @@ To track down missing translation strings, run Hugo with the `--i18n-warnings` f
|
||||||
i18n|MISSING_TRANSLATION|en|wordCount
|
i18n|MISSING_TRANSLATION|en|wordCount
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Menus
|
### Menus
|
||||||
|
|
||||||
You can define your menus for each language independently. The [creation of a menu]({{< relref "extras/menus.md" >}}) works analogous to earlier versions of Hugo, except that they have to be defined in their language-specific block in the configuration file:
|
You can define your menus for each language independently. The [creation of a menu]({{< relref "extras/menus.md" >}}) works analogous to earlier versions of Hugo, except that they have to be defined in their language-specific block in the configuration file:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
DefaultContentLanguage = "en"
|
defaultContentLanguage = "en"
|
||||||
|
|
||||||
[languages.en]
|
[languages.en]
|
||||||
weight = 0
|
weight = 0
|
||||||
|
|
|
@ -79,7 +79,7 @@ aliases:
|
||||||
|
|
||||||
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
|
When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
|
||||||
|
|
||||||
Assuming a baseurl of `mysite.tld`, the contents of the html file will look something like:
|
Assuming a baseURL of `mysite.tld`, the contents of the html file will look something like:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
|
@ -127,7 +127,7 @@ And the equivalent example `config.yaml`:
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
**NOTE:** The URLs must be relative to the context root. If the `BaseURL` is `http://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will overide the BaseURL. If the `URL` is `http://subdomain.example.com/`, the output will be `http://subdomain.example.com`.
|
**NOTE:** The URLs must be relative to the context root. If the `baseURL` is `http://example.com/mysite/`, then the URLs in the menu must not include the context root `mysite`. Using an absolute URL will overide the baseURL. If the `URL` is `http://subdomain.example.com/`, the output will be `http://subdomain.example.com`.
|
||||||
|
|
||||||
## Nesting
|
## Nesting
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@ All nesting of content is done via the `parent` field.
|
||||||
The parent of an entry should be the identifier of another entry.
|
The parent of an entry should be the identifier of another entry.
|
||||||
Identifier should be unique (within a menu).
|
Identifier should be unique (within a menu).
|
||||||
|
|
||||||
The following order is used to determine an Identifier:
|
The following order is used to determine an Identifier:
|
||||||
|
|
||||||
> Name > LinkTitle > Title.
|
> Name > LinkTitle > Title.
|
||||||
|
|
||||||
This means that the title will be used unless
|
This means that the title will be used unless
|
||||||
linktitle is present, etc. In practice Name and Identifier are never
|
linktitle is present, etc. In practice Name and Identifier are never
|
||||||
|
|
|
@ -35,11 +35,11 @@ Organization](/content/organization/) for more details.
|
||||||
|
|
||||||
By default, all relative URLs encountered in the input are left unmodified,
|
By default, all relative URLs encountered in the input are left unmodified,
|
||||||
e.g. `/css/foo.css` would stay as `/css/foo.css`,
|
e.g. `/css/foo.css` would stay as `/css/foo.css`,
|
||||||
i.e. `canonifyurls` defaults to `false`.
|
i.e. `canonifyURLs` defaults to `false`.
|
||||||
|
|
||||||
By setting `canonifyurls` to `true`, all relative URLs would instead
|
By setting `canonifyURLs` to `true`, all relative URLs would instead
|
||||||
be *canonicalized* using `baseurl`. For example, assuming you have
|
be *canonicalized* using `baseURL`. For example, assuming you have
|
||||||
`baseurl = http://yoursite.example.com/` defined in the site-wide
|
`baseURL = http://yoursite.example.com/` defined in the site-wide
|
||||||
`config.toml`, the relative URL `/css/foo.css` would be turned into
|
`config.toml`, the relative URL `/css/foo.css` would be turned into
|
||||||
the absolute URL `http://yoursite.example.com/css/foo.css`.
|
the absolute URL `http://yoursite.example.com/css/foo.css`.
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ Benefits of non-canonicalization include being able to have resource inclusion
|
||||||
be scheme-relative, so that http vs https can be decided based on how this
|
be scheme-relative, so that http vs https can be decided based on how this
|
||||||
page was retrieved.
|
page was retrieved.
|
||||||
|
|
||||||
> Note: In the May 2014 release of Hugo v0.11, the default value of `canonifyurls` was switched from `true` to `false`, which we think is the better default and should continue to be the case going forward. So, please verify and adjust your website accordingly if you are upgrading from v0.10 or older versions.
|
> Note: In the May 2014 release of Hugo v0.11, the default value of `canonifyURLs` was switched from `true` to `false`, which we think is the better default and should continue to be the case going forward. So, please verify and adjust your website accordingly if you are upgrading from v0.10 or older versions.
|
||||||
|
|
||||||
To find out the current value of `canonifyurls` for your website, you may use the handy `hugo config` command added in v0.13:
|
To find out the current value of `canonifyURLs` for your website, you may use the handy `hugo config` command added in v0.13:
|
||||||
|
|
||||||
hugo config | grep -i canon
|
hugo config | grep -i canon
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ times decreased anywhere from 10% to 99%.
|
||||||
* Use absolute path when editing with editor {{<gh 1589>}}
|
* Use absolute path when editing with editor {{<gh 1589>}}
|
||||||
* Fix hugo server "Watching for changes" path display {{<gh 1721>}}
|
* Fix hugo server "Watching for changes" path display {{<gh 1721>}}
|
||||||
* Do not strip special characters out of URLs {{<gh 1292>}}
|
* Do not strip special characters out of URLs {{<gh 1292>}}
|
||||||
* Fix `RSSLink` when uglyurls are enabled {{<gh 175>}}
|
* Fix `RSSLink` when uglyURLs are enabled {{<gh 175>}}
|
||||||
* Get BaseURL from viper in server mode {{<gh 1821>}}
|
* Get BaseURL from viper in server mode {{<gh 1821>}}
|
||||||
* Fix shortcode handling in RST {{<gh 1904>}}
|
* Fix shortcode handling in RST {{<gh 1904>}}
|
||||||
* Use default sitemap configuration for homepage {{<gh 1304>}}
|
* Use default sitemap configuration for homepage {{<gh 1304>}}
|
||||||
|
@ -411,7 +411,7 @@ Hugo also depends on a lot of other great projects. A big thanks to all of our d
|
||||||
* More Pygments highlighting options, including `line numbers`
|
* More Pygments highlighting options, including `line numbers`
|
||||||
* Show help information to Windows users who try to double click on `hugo.exe`.
|
* Show help information to Windows users who try to double click on `hugo.exe`.
|
||||||
* Add `bind` flag to `hugo server` to set the interface to which the server will bind
|
* Add `bind` flag to `hugo server` to set the interface to which the server will bind
|
||||||
* Add support for `canonifyurls` in `srcset`
|
* Add support for `canonifyURLs` in `srcset`
|
||||||
* Add shortcode support for HTML (content) files
|
* Add shortcode support for HTML (content) files
|
||||||
* Allow the same `shortcode` to be used with or without inline content
|
* Allow the same `shortcode` to be used with or without inline content
|
||||||
* Configurable RSS output filename
|
* Configurable RSS output filename
|
||||||
|
@ -420,7 +420,7 @@ Hugo also depends on a lot of other great projects. A big thanks to all of our d
|
||||||
* Fix panic with paginator and zero pages in result set.
|
* Fix panic with paginator and zero pages in result set.
|
||||||
* Fix crossrefs on Windows.
|
* Fix crossrefs on Windows.
|
||||||
* Fix `eq` and `ne` template functions when used with a raw number combined with the result of `add`, `sub` etc.
|
* Fix `eq` and `ne` template functions when used with a raw number combined with the result of `add`, `sub` etc.
|
||||||
* Fix paginator with uglyurls
|
* Fix paginator with uglyURLs
|
||||||
* Fix {{< gh 998 >}}, supporting UTF8 characters in Permalinks.
|
* Fix {{< gh 998 >}}, supporting UTF8 characters in Permalinks.
|
||||||
|
|
||||||
## Notices
|
## Notices
|
||||||
|
|
|
@ -49,7 +49,7 @@ Three periods end the document:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
baseurl: "http://yoursite.example.com/"
|
baseURL: "http://yoursite.example.com/"
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
Following is an example TOML configuration file with some default values.
|
Following is an example TOML configuration file with some default values.
|
||||||
|
@ -57,12 +57,12 @@ The values under `[params]` will populate the `.Site.Params` variable
|
||||||
for use in templates:
|
for use in templates:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
contentdir = "content"
|
contentDir = "content"
|
||||||
layoutdir = "layouts"
|
layoutDir = "layouts"
|
||||||
publishdir = "public"
|
publishDir = "public"
|
||||||
builddrafts = false
|
buildDrafts = false
|
||||||
baseurl = "http://yoursite.example.com/"
|
baseURL = "http://yoursite.example.com/"
|
||||||
canonifyurls = true
|
canonifyURLs = true
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
category = "categories"
|
category = "categories"
|
||||||
|
@ -76,9 +76,9 @@ Here is a YAML configuration file which sets a few more options:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
baseurl: "http://yoursite.example.com/"
|
baseURL: "http://yoursite.example.com/"
|
||||||
title: "Yoyodyne Widget Blogging"
|
title: "Yoyodyne Widget Blogging"
|
||||||
footnotereturnlinkcontents: "↩"
|
footnoteReturnLinkContents: "↩"
|
||||||
permalinks:
|
permalinks:
|
||||||
post: /:year/:month/:title/
|
post: /:year/:month/:title/
|
||||||
params:
|
params:
|
||||||
|
@ -97,7 +97,7 @@ Following is a list of Hugo-defined variables you can configure,
|
||||||
along with their current, default values:
|
along with their current, default values:
|
||||||
|
|
||||||
---
|
---
|
||||||
archetypedir: "archetype"
|
archetypeDir: "archetype"
|
||||||
# hostname (and path) to the root, e.g. http://spf13.com/
|
# hostname (and path) to the root, e.g. http://spf13.com/
|
||||||
baseURL: ""
|
baseURL: ""
|
||||||
# include content marked as draft
|
# include content marked as draft
|
||||||
|
@ -111,14 +111,14 @@ along with their current, default values:
|
||||||
canonifyURLs: false
|
canonifyURLs: false
|
||||||
# config file (default is path/config.yaml|json|toml)
|
# config file (default is path/config.yaml|json|toml)
|
||||||
config: "config.toml"
|
config: "config.toml"
|
||||||
contentdir: "content"
|
contentDir: "content"
|
||||||
dataDir: "data"
|
dataDir: "data"
|
||||||
defaultExtension: "html"
|
defaultExtension: "html"
|
||||||
defaultLayout: "post"
|
defaultLayout: "post"
|
||||||
# Missing translations will default to this content language
|
# Missing translations will default to this content language
|
||||||
DefaultContentLanguage: "en"
|
defaultContentLanguage: "en"
|
||||||
# Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
|
# Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
|
||||||
DefaultContentLanguageInSubdir: false
|
defaultContentLanguageInSubdir: false
|
||||||
disableLiveReload: false
|
disableLiveReload: false
|
||||||
# Do not build RSS files
|
# Do not build RSS files
|
||||||
disableRSS: false
|
disableRSS: false
|
||||||
|
@ -142,7 +142,7 @@ along with their current, default values:
|
||||||
# google analytics tracking id
|
# google analytics tracking id
|
||||||
googleAnalytics: ""
|
googleAnalytics: ""
|
||||||
languageCode: ""
|
languageCode: ""
|
||||||
layoutdir: "layouts"
|
layoutDir: "layouts"
|
||||||
# Enable Logging
|
# Enable Logging
|
||||||
log: false
|
log: false
|
||||||
# Log File path (if set, logging enabled automatically)
|
# Log File path (if set, logging enabled automatically)
|
||||||
|
@ -160,7 +160,7 @@ along with their current, default values:
|
||||||
# Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu")
|
# Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu")
|
||||||
preserveTaxonomyNames: false
|
preserveTaxonomyNames: false
|
||||||
# filesystem path to write files to
|
# filesystem path to write files to
|
||||||
publishdir: "public"
|
publishDir: "public"
|
||||||
# enables syntax guessing for code fences without specified language
|
# enables syntax guessing for code fences without specified language
|
||||||
pygmentsCodeFencesGuessSyntax: false
|
pygmentsCodeFencesGuessSyntax: false
|
||||||
# color-codes for highlighting derived from this style
|
# color-codes for highlighting derived from this style
|
||||||
|
@ -171,11 +171,11 @@ along with their current, default values:
|
||||||
sitemap:
|
sitemap:
|
||||||
# filesystem path to read files relative from
|
# filesystem path to read files relative from
|
||||||
source: ""
|
source: ""
|
||||||
staticdir: "static"
|
staticDir: "static"
|
||||||
# display memory and timing of different steps of the program
|
# display memory and timing of different steps of the program
|
||||||
stepAnalysis: false
|
stepAnalysis: false
|
||||||
# theme to use (located by default in /themes/THEMENAME/)
|
# theme to use (located by default in /themes/THEMENAME/)
|
||||||
themesdir: "themes"
|
themesDir: "themes"
|
||||||
theme: ""
|
theme: ""
|
||||||
title: ""
|
title: ""
|
||||||
# if true, use /filename.html instead of /filename/
|
# if true, use /filename.html instead of /filename/
|
||||||
|
|
|
@ -80,7 +80,7 @@ can see what the pages look like.
|
||||||
|
|
||||||
The second component is used when you're ready to publish your web
|
The second component is used when you're ready to publish your web
|
||||||
site to the computer running your website. Running Hugo without any
|
site to the computer running your website. Running Hugo without any
|
||||||
actions will rebuild your entire web site using the `baseurl` setting
|
actions will rebuild your entire web site using the `baseURL` setting
|
||||||
from your site's configuration file. That's required to have your page
|
from your site's configuration file. That's required to have your page
|
||||||
links work properly with most hosting companies.
|
links work properly with most hosting companies.
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ As mentioned in the command output, `bookshelf` directory has 5 sub-directories
|
||||||
|
|
||||||
* **archetypes**: You can create new content files in Hugo using the `hugo new` command. When you run that command, it adds few configuration properties to the post like date and title. [Archetype]({{< relref "content/archetypes.md" >}}) allows you to define your own configuration properties that will be added to the post front matter whenever `hugo new` command is used.
|
* **archetypes**: You can create new content files in Hugo using the `hugo new` command. When you run that command, it adds few configuration properties to the post like date and title. [Archetype]({{< relref "content/archetypes.md" >}}) allows you to define your own configuration properties that will be added to the post front matter whenever `hugo new` command is used.
|
||||||
|
|
||||||
* **config.toml**: Every website should have a configuration file at the root. By default, the configuration file uses `TOML` format but you can also use `YAML` or `JSON` formats as well. [TOML](https://github.com/toml-lang/toml) is minimal configuration file format that's easy to read due to obvious semantics. The configuration settings mentioned in the `config.toml` are applied to the full site. These configuration settings include `baseurl` and `title` of the website.
|
* **config.toml**: Every website should have a configuration file at the root. By default, the configuration file uses `TOML` format but you can also use `YAML` or `JSON` formats as well. [TOML](https://github.com/toml-lang/toml) is minimal configuration file format that's easy to read due to obvious semantics. The configuration settings mentioned in the `config.toml` are applied to the full site. These configuration settings include `baseURL` and `title` of the website.
|
||||||
|
|
||||||
* **content**: This is where you will store content of the website. Inside content, you will create sub-directories for different sections. Let's suppose your website has three actions -- `blog`, `article`, and `tutorial` then you will have three different directories for each of them inside the `content` directory. The name of the section i.e. `blog`, `article`, or `tutorial` will be used by Hugo to apply a specific layout applicable to that section.
|
* **content**: This is where you will store content of the website. Inside content, you will create sub-directories for different sections. Let's suppose your website has three actions -- `blog`, `article`, and `tutorial` then you will have three different directories for each of them inside the `content` directory. The name of the section i.e. `blog`, `article`, or `tutorial` will be used by Hugo to apply a specific layout applicable to that section.
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ The website uses the dummy values specified in `bookshelf/config.toml`.
|
||||||
Let's update the configuration.
|
Let's update the configuration.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
baseurl = "http://example.org/"
|
baseURL = "http://example.org/"
|
||||||
languageCode = "en-us"
|
languageCode = "en-us"
|
||||||
title = "Shekhar Gulati Book Reviews"
|
title = "Shekhar Gulati Book Reviews"
|
||||||
|
|
||||||
|
@ -484,10 +484,10 @@ Now, commenting will be enabled in your blog.
|
||||||
|
|
||||||
To generate Hugo website source you can use
|
To generate Hugo website source you can use
|
||||||
to deploy your website on GitHub pages,
|
to deploy your website on GitHub pages,
|
||||||
first edit `bookshelf/config.toml`, changing the `baseurl` line to:
|
first edit `bookshelf/config.toml`, changing the `baseURL` line to:
|
||||||
|
|
||||||
```
|
```
|
||||||
baseurl = "https://<your GitHub username>.github.io/bookshelf/"
|
baseURL = "https://<your GitHub username>.github.io/bookshelf/"
|
||||||
```
|
```
|
||||||
|
|
||||||
Then type the following command.
|
Then type the following command.
|
||||||
|
|
|
@ -69,7 +69,7 @@ It makes use of [partial templates](/templates/partials/)
|
||||||
|
|
||||||
{{ partial "header.html" . }}
|
{{ partial "header.html" . }}
|
||||||
{{ partial "subheader.html" . }}
|
{{ partial "subheader.html" . }}
|
||||||
{{ $baseurl := .Site.BaseURL }}
|
{{ $baseURL := .Site.BaseURL }}
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
|
@ -88,12 +88,12 @@ It makes use of [partial templates](/templates/partials/)
|
||||||
</section>
|
</section>
|
||||||
<ul id="categories">
|
<ul id="categories">
|
||||||
{{ range .Params.topics }}
|
{{ range .Params.topics }}
|
||||||
<li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
|
<li><a href="{{ $baseURL }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="tags">
|
<ul id="tags">
|
||||||
{{ range .Params.tags }}
|
{{ range .Params.tags }}
|
||||||
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
|
<li> <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -118,7 +118,7 @@ It makes use of [partial templates](/templates/partials/)
|
||||||
|
|
||||||
{{ partial "header.html" . }}
|
{{ partial "header.html" . }}
|
||||||
{{ partial "subheader.html" . }}
|
{{ partial "subheader.html" . }}
|
||||||
{{ $baseurl := .Site.BaseURL }}
|
{{ $baseURL := .Site.BaseURL }}
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
<h1 id="title">{{ .Title }}</h1>
|
<h1 id="title">{{ .Title }}</h1>
|
||||||
|
@ -137,12 +137,12 @@ It makes use of [partial templates](/templates/partials/)
|
||||||
</section>
|
</section>
|
||||||
<ul id="categories">
|
<ul id="categories">
|
||||||
{{ range .Params.topics }}
|
{{ range .Params.topics }}
|
||||||
<li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
|
<li><a href="{{ $baseURL }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
<ul id="tags">
|
<ul id="tags">
|
||||||
{{ range .Params.tags }}
|
{{ range .Params.tags }}
|
||||||
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
|
<li> <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -267,7 +267,7 @@ access this from within the loop, you will likely want to do one of the followin
|
||||||
{{ $title := .Site.Title }}
|
{{ $title := .Site.Title }}
|
||||||
{{ range .Params.tags }}
|
{{ range .Params.tags }}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a>
|
<a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a>
|
||||||
- {{ $title }}
|
- {{ $title }}
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -281,7 +281,7 @@ access this from within the loop, you will likely want to do one of the followin
|
||||||
|
|
||||||
{{ range .Params.tags }}
|
{{ range .Params.tags }}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a>
|
<a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a>
|
||||||
- {{ $.Site.Title }}
|
- {{ $.Site.Title }}
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -159,7 +159,7 @@ Also available is `.Site` which has the following:
|
||||||
**.Site.AllPages** Array of all pages regardless of their translation.<br>
|
**.Site.AllPages** Array of all pages regardless of their translation.<br>
|
||||||
**.Site.Params** A container holding the values from the `params` section of your site configuration file. For example, a TOML config file might look like this:
|
**.Site.Params** A container holding the values from the `params` section of your site configuration file. For example, a TOML config file might look like this:
|
||||||
|
|
||||||
baseurl = "http://yoursite.example.com/"
|
baseURL = "http://yoursite.example.com/"
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
description = "Tesla's Awesome Hugo Site"
|
description = "Tesla's Awesome Hugo Site"
|
||||||
|
|
|
@ -11,7 +11,7 @@ title: Create a Multilingual Site
|
||||||
weight: 10
|
weight: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
> **Note:** Since v0.17 Hugo has built-in support for the creation of multilingual website. [Read more about it]({{< relref "content/multilingual.md" >}}).
|
> **Note:** Since v0.17 Hugo has built-in support for the creation of multilingual website. [Read more about it]({{< relref "content/multilingual.md" >}}).
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ Create your site configs in the root of your repository, for example for an Engl
|
||||||
**English Config `config_en.toml`**:
|
**English Config `config_en.toml`**:
|
||||||
|
|
||||||
~~~toml
|
~~~toml
|
||||||
baseurl = "http://acme.com/"
|
baseURL = "http://acme.com/"
|
||||||
title = "Acme Inc."
|
title = "Acme Inc."
|
||||||
contentdir = "content/en"
|
contentDir = "content/en"
|
||||||
publishdir = "public/en"
|
publishDir = "public/en"
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
locale = "en-US"
|
locale = "en-US"
|
||||||
|
@ -42,10 +42,10 @@ publishdir = "public/en"
|
||||||
**Japanese Config `config_ja.toml`**:
|
**Japanese Config `config_ja.toml`**:
|
||||||
|
|
||||||
~~~toml
|
~~~toml
|
||||||
baseurl = "http://acme.jp/"
|
baseURL = "http://acme.jp/"
|
||||||
title = "有限会社アクミー"
|
title = "有限会社アクミー"
|
||||||
contentdir = "content/ja"
|
contentDir = "content/ja"
|
||||||
publishdir = "public/ja"
|
publishDir = "public/ja"
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
locale = "ja-JP"
|
locale = "ja-JP"
|
||||||
|
@ -60,16 +60,16 @@ Create `.yaml` (or `.json` or `.toml`) files for each language, under `/data/tra
|
||||||
**English Strings `en-US.yaml`**:
|
**English Strings `en-US.yaml`**:
|
||||||
|
|
||||||
~~~yaml
|
~~~yaml
|
||||||
topslogan: Acme Inc.
|
topSlogan: Acme Inc.
|
||||||
topsubslogan: You'll love us
|
topSubslogan: You'll love us
|
||||||
...
|
...
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
**Japanese Strings `ja-JP.yaml`**:
|
**Japanese Strings `ja-JP.yaml`**:
|
||||||
|
|
||||||
~~~yaml
|
~~~yaml
|
||||||
topslogan: 有限会社アクミー
|
topSlogan: 有限会社アクミー
|
||||||
topsubslogan: キット勝つぞ
|
topSubslogan: キット勝つぞ
|
||||||
...
|
...
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ Now you can reference the strings in your templates. One way is to do it like in
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topslogan }}</h1>
|
<h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSlogan }}</h1>
|
||||||
<h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topsubslogan }}</h3>
|
<h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSubslogan }}</h3>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -126,7 +126,7 @@ At the time of this writing, Golang does not yet have support for internationali
|
||||||
</time>
|
</time>
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file.
|
This technique extracts the day, month and year by specifying ``.Date.Day``, ``.Date.Month``, and ``.Date.Year``, and uses the month number as a key, when indexing the month name data file.
|
||||||
|
|
||||||
## Create Multilingual Content
|
## Create Multilingual Content
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ So, let's edit your configuration file to add the theme name:
|
||||||
```toml
|
```toml
|
||||||
$ vi config.toml
|
$ vi config.toml
|
||||||
theme = "zafta"
|
theme = "zafta"
|
||||||
baseurl = "http://example.org/"
|
baseURL = "http://example.org/"
|
||||||
title = "My New Hugo Site"
|
title = "My New Hugo Site"
|
||||||
languageCode = "en-us"
|
languageCode = "en-us"
|
||||||
:wq
|
:wq
|
||||||
|
@ -1074,13 +1074,13 @@ templates _much_ easier — so, I'll cover them, now.
|
||||||
### Base URL
|
### Base URL
|
||||||
|
|
||||||
While developing and testing your theme, did you notice that the links in the
|
While developing and testing your theme, did you notice that the links in the
|
||||||
rendered `./public/index.html` file use the full "baseurl" from your
|
rendered `./public/index.html` file use the full "baseURL" from your
|
||||||
`./config.toml` file? That's because those files are intended to be deployed
|
`./config.toml` file? That's because those files are intended to be deployed
|
||||||
to your web server.
|
to your web server.
|
||||||
|
|
||||||
Whenever you test your theme, you start Hugo in web server mode
|
Whenever you test your theme, you start Hugo in web server mode
|
||||||
(with `hugo server`) and connect to it with your web browser.
|
(with `hugo server`) and connect to it with your web browser.
|
||||||
That command is smart enough to replace the "baseurl" with
|
That command is smart enough to replace the "baseURL" with
|
||||||
`http://localhost:1313` on the fly, so that the links automatically
|
`http://localhost:1313` on the fly, so that the links automatically
|
||||||
work for you.
|
work for you.
|
||||||
|
|
||||||
|
|
|
@ -31,22 +31,22 @@ As our goal is to host a website using GitHub Pages, it is natural for us to hos
|
||||||
|
|
||||||
### Write a `config.yaml` File
|
### Write a `config.yaml` File
|
||||||
|
|
||||||
The very first step in creating a new Hugo site is to [write the config file](/overview/configuration/). This config file is important for at least two reasons: (1) this is where site-wide settings (like the websites `baseurl`) go, and (2) the config file dictates to some extent how Hugo will generate the website. For the example website I created a file `config.yaml` with the following contents
|
The very first step in creating a new Hugo site is to [write the config file](/overview/configuration/). This config file is important for at least two reasons: (1) this is where site-wide settings (like the websites `baseURL`) go, and (2) the config file dictates to some extent how Hugo will generate the website. For the example website I created a file `config.yaml` with the following contents
|
||||||
|
|
||||||
---
|
---
|
||||||
contentdir: "content"
|
contentDir: "content"
|
||||||
layoutdir: "layouts"
|
layoutDir: "layouts"
|
||||||
publishdir: "public"
|
publishDir: "public"
|
||||||
indexes:
|
indexes:
|
||||||
category: "categories"
|
category: "categories"
|
||||||
baseurl: "http://spencerlyon2.github.io/hugo_gh_blog"
|
baseURL: "http://spencerlyon2.github.io/hugo_gh_blog"
|
||||||
title: "Hugo Blog Template for GitHub Pages"
|
title: "Hugo Blog Template for GitHub Pages"
|
||||||
canonifyurls: true
|
canonifyURLs: true
|
||||||
...
|
...
|
||||||
|
|
||||||
> **Caveat:** Hugo's former default of `canonifyurls: true` has been changed
|
> **Caveat:** Hugo's former default of `canonifyURLs: true` has been changed
|
||||||
> to `false` since this tutorial has written. **Please make sure you manually
|
> to `false` since this tutorial has written. **Please make sure you manually
|
||||||
> add `canonifyurls: true` to your `config.yaml`** if you are using Spencer's
|
> add `canonifyURLs: true` to your `config.yaml`** if you are using Spencer's
|
||||||
> https://github.com/spencerlyon2/hugo_gh_blog for this tutorial, or you *will*
|
> https://github.com/spencerlyon2/hugo_gh_blog for this tutorial, or you *will*
|
||||||
> run into problems such as the CSS files not loading.
|
> run into problems such as the CSS files not loading.
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ The very first step in creating a new Hugo site is to [write the config file](/o
|
||||||
|
|
||||||
### Define Structure of Website
|
### Define Structure of Website
|
||||||
|
|
||||||
Hugo assumes that you organize the content of your site in a meaningful way and uses the same structure to render the website. Notice that we have the line `contentdir: "content"` in our configuration file. This means that all the actual content of the website should be placed somewhere within a folder named `content`. Hugo treats all directories in `content` as sections. For our example we only need one section: a place to hold our blog posts. So we created two new folders:
|
Hugo assumes that you organize the content of your site in a meaningful way and uses the same structure to render the website. Notice that we have the line `contentDir: "content"` in our configuration file. This means that all the actual content of the website should be placed somewhere within a folder named `content`. Hugo treats all directories in `content` as sections. For our example we only need one section: a place to hold our blog posts. So we created two new folders:
|
||||||
|
|
||||||
```
|
```
|
||||||
▾ <root>/
|
▾ <root>/
|
||||||
|
@ -115,7 +115,7 @@ The keys set in this section are the mandatory `title` and `date` as well as the
|
||||||
|
|
||||||
Once the site is set up and working properly, we need to push it to the correct branch of a GitHub repository so the website can be served through GitHub Pages. There are many ways to do this. Here I will show the workflow I currently use to manage my websites that are hosted through GitHub Pages.
|
Once the site is set up and working properly, we need to push it to the correct branch of a GitHub repository so the website can be served through GitHub Pages. There are many ways to do this. Here I will show the workflow I currently use to manage my websites that are hosted through GitHub Pages.
|
||||||
|
|
||||||
GitHub Pages will serve up a website for any repository that has a branch called `gh-pages` with a valid `index.html` file at that branch's root. A typical workflow might be to keep the content of a website on the `master` branch of a repository and the generated website on the `gh-pages` branch. This provides nice separation between input and output, but can be very tedious to work with. As a workaround, we will use the `git subtree` family of commands to have the `public` directory (or whatever `publishdir` is set to in your `config.yaml`) mirror the root of the `gh-pages` branch of the repository. This will allow us to do all our work on the `master` branch, run Hugo to have the site output into the `public` directory, and then push that directory directly to the correct place for GitHub Pages to serve our site.
|
GitHub Pages will serve up a website for any repository that has a branch called `gh-pages` with a valid `index.html` file at that branch's root. A typical workflow might be to keep the content of a website on the `master` branch of a repository and the generated website on the `gh-pages` branch. This provides nice separation between input and output, but can be very tedious to work with. As a workaround, we will use the `git subtree` family of commands to have the `public` directory (or whatever `publishDir` is set to in your `config.yaml`) mirror the root of the `gh-pages` branch of the repository. This will allow us to do all our work on the `master` branch, run Hugo to have the site output into the `public` directory, and then push that directory directly to the correct place for GitHub Pages to serve our site.
|
||||||
|
|
||||||
To get this properly set up, we will execute a series of commands at the terminal. I will include all of them in one place here for easy copy and paste, and will explain what each line does via comments. Note that this is to be run from the `<root>` directory (wherever the `content` and `layout` folders of your Hugo project live). Also note that you will need to change the commands that have the example repository GitHub address so that they point to your repo.
|
To get this properly set up, we will execute a series of commands at the terminal. I will include all of them in one place here for easy copy and paste, and will explain what each line does via comments. Note that this is to be run from the `<root>` directory (wherever the `content` and `layout` folders of your Hugo project live). Also note that you will need to change the commands that have the example repository GitHub address so that they point to your repo.
|
||||||
|
|
||||||
|
@ -190,22 +190,22 @@ To build all draft posts *(If you only have drafts, no site will be generated)*
|
||||||
**Deploy.sh:**
|
**Deploy.sh:**
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"
|
||||||
|
|
||||||
# Build the project.
|
# Build the project.
|
||||||
hugo
|
hugo
|
||||||
|
|
||||||
# Add changes to git.
|
# Add changes to git.
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
# Commit changes.
|
# Commit changes.
|
||||||
msg="rebuilding site `date`"
|
msg="rebuilding site `date`"
|
||||||
if [ $# -eq 1 ]
|
if [ $# -eq 1 ]
|
||||||
then msg="$1"
|
then msg="$1"
|
||||||
fi
|
fi
|
||||||
git commit -m "$msg"
|
git commit -m "$msg"
|
||||||
|
|
||||||
# Push source and build repos.
|
# Push source and build repos.
|
||||||
git push origin master
|
git push origin master
|
||||||
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
git subtree push --prefix=public git@github.com:spencerlyon2/hugo_gh_blog.git gh-pages
|
||||||
|
|
|
@ -46,7 +46,7 @@ The default is for Jekyll to publish to `_site` and for Hugo to publish to `publ
|
||||||
|
|
||||||
{
|
{
|
||||||
..
|
..
|
||||||
"publishdir": "_site",
|
"publishDir": "_site",
|
||||||
..
|
..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
baseurl = "http://blog.hugoexample.com/"
|
baseURL = "http://blog.hugoexample.com/"
|
||||||
languageCode = "en-us"
|
languageCode = "en-us"
|
||||||
title = "Hugo Example Blog"
|
title = "Hugo Example Blog"
|
||||||
canonifyurls = true
|
canonifyURLs = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
baseurl = "http://example.com"
|
baseURL = "http://example.com"
|
||||||
|
|
||||||
[taxonomies]
|
[taxonomies]
|
||||||
tag = "tags"
|
tag = "tags"
|
||||||
group = "groups"
|
group = "groups"
|
||||||
menu = "menu"
|
menu = "menu"
|
||||||
|
|
|
@ -49,7 +49,7 @@ func Config() ConfigProvider {
|
||||||
return currentConfigProvider
|
return currentConfigProvider
|
||||||
}
|
}
|
||||||
// Some tests rely on this. We will fix that, eventually.
|
// Some tests rely on this. We will fix that, eventually.
|
||||||
return viper.Get("CurrentContentLanguage").(ConfigProvider)
|
return viper.Get("currentContentLanguage").(ConfigProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CurrentPathSpec returns the current PathSpec.
|
// CurrentPathSpec returns the current PathSpec.
|
||||||
|
|
|
@ -182,8 +182,8 @@ func BytesToHTML(b []byte) template.HTML {
|
||||||
// getHTMLRenderer creates a new Blackfriday HTML Renderer with the given configuration.
|
// getHTMLRenderer creates a new Blackfriday HTML Renderer with the given configuration.
|
||||||
func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
||||||
renderParameters := blackfriday.HtmlRendererParameters{
|
renderParameters := blackfriday.HtmlRendererParameters{
|
||||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"),
|
||||||
FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
|
FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"),
|
||||||
}
|
}
|
||||||
|
|
||||||
b := len(ctx.DocumentID) != 0
|
b := len(ctx.DocumentID) != 0
|
||||||
|
@ -271,8 +271,8 @@ func markdownRender(ctx *RenderingContext) []byte {
|
||||||
// getMmarkHTMLRenderer creates a new mmark HTML Renderer with the given configuration.
|
// getMmarkHTMLRenderer creates a new mmark HTML Renderer with the given configuration.
|
||||||
func getMmarkHTMLRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
|
func getMmarkHTMLRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer {
|
||||||
renderParameters := mmark.HtmlRendererParameters{
|
renderParameters := mmark.HtmlRendererParameters{
|
||||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"),
|
||||||
FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"),
|
FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"),
|
||||||
}
|
}
|
||||||
|
|
||||||
b := len(ctx.DocumentID) != 0
|
b := len(ctx.DocumentID) != 0
|
||||||
|
|
|
@ -34,8 +34,8 @@ type HugoHTMLRenderer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
func (renderer *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
|
||||||
if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
|
if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
||||||
opts := viper.GetString("PygmentsOptions")
|
opts := viper.GetString("pygmentsOptions")
|
||||||
str := html.UnescapeString(string(text))
|
str := html.UnescapeString(string(text))
|
||||||
out.WriteString(Highlight(str, lang, opts))
|
out.WriteString(Highlight(str, lang, opts))
|
||||||
} else {
|
} else {
|
||||||
|
@ -117,7 +117,7 @@ type HugoMmarkHTMLRenderer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (renderer *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
|
func (renderer *HugoMmarkHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string, caption []byte, subfigure bool, callouts bool) {
|
||||||
if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) {
|
if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) {
|
||||||
str := html.UnescapeString(string(text))
|
str := html.UnescapeString(string(text))
|
||||||
out.WriteString(Highlight(str, lang, ""))
|
out.WriteString(Highlight(str, lang, ""))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -62,11 +62,11 @@ func TestCodeFence(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
viper.Set("PygmentsStyle", "monokai")
|
viper.Set("pygmentsStyle", "monokai")
|
||||||
viper.Set("PygmentsUseClasses", true)
|
viper.Set("pygmentsUseClasses", true)
|
||||||
|
|
||||||
for i, d := range data {
|
for i, d := range data {
|
||||||
viper.Set("PygmentsCodeFences", d.enabled)
|
viper.Set("pygmentsCodeFences", d.enabled)
|
||||||
|
|
||||||
result := render(d.input)
|
result := render(d.input)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ func NewLanguage(lang string) *Language {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultLanguage() *Language {
|
func NewDefaultLanguage() *Language {
|
||||||
defaultLang := viper.GetString("DefaultContentLanguage")
|
defaultLang := viper.GetString("defaultContentLanguage")
|
||||||
|
|
||||||
if defaultLang == "" {
|
if defaultLang == "" {
|
||||||
defaultLang = "en"
|
defaultLang = "en"
|
||||||
|
@ -83,7 +83,7 @@ func (l *Language) Params() map[string]interface{} {
|
||||||
// Merge with global config.
|
// Merge with global config.
|
||||||
// TODO(bep) consider making this part of a constructor func.
|
// TODO(bep) consider making this part of a constructor func.
|
||||||
|
|
||||||
globalParams := viper.GetStringMap("Params")
|
globalParams := viper.GetStringMap("params")
|
||||||
for k, v := range globalParams {
|
for k, v := range globalParams {
|
||||||
if _, ok := l.params[k]; !ok {
|
if _, ok := l.params[k]; !ok {
|
||||||
l.params[k] = v
|
l.params[k] = v
|
||||||
|
|
|
@ -154,13 +154,13 @@ func AbsPathify(inPath string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bep): Consider moving workingDir to argument list
|
// TODO(bep): Consider moving workingDir to argument list
|
||||||
return filepath.Clean(filepath.Join(viper.GetString("WorkingDir"), inPath))
|
return filepath.Clean(filepath.Join(viper.GetString("workingDir"), inPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStaticDirPath returns the absolute path to the static file dir
|
// GetStaticDirPath returns the absolute path to the static file dir
|
||||||
// for the current Hugo project.
|
// for the current Hugo project.
|
||||||
func GetStaticDirPath() string {
|
func GetStaticDirPath() string {
|
||||||
return AbsPathify(viper.GetString("StaticDir"))
|
return AbsPathify(viper.GetString("staticDir"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetThemeDir gets the root directory of the current theme, if there is one.
|
// GetThemeDir gets the root directory of the current theme, if there is one.
|
||||||
|
@ -342,7 +342,7 @@ func GetRelativePath(path, base string) (final string, err error) {
|
||||||
// PaginateAliasPath creates a path used to access the aliases in the paginator.
|
// PaginateAliasPath creates a path used to access the aliases in the paginator.
|
||||||
func PaginateAliasPath(base string, page int) string {
|
func PaginateAliasPath(base string, page int) string {
|
||||||
paginatePath := Config().GetString("paginatePath")
|
paginatePath := Config().GetString("paginatePath")
|
||||||
uglify := viper.GetBool("UglyURLs")
|
uglify := viper.GetBool("uglyURLs")
|
||||||
var p string
|
var p string
|
||||||
if base != "" {
|
if base != "" {
|
||||||
p = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page))
|
p = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page))
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func initCommonTestConfig() {
|
func initCommonTestConfig() {
|
||||||
viper.Set("CurrentContentLanguage", NewLanguage("en"))
|
viper.Set("currentContentLanguage", NewLanguage("en"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMakePath(t *testing.T) {
|
func TestMakePath(t *testing.T) {
|
||||||
|
@ -61,7 +61,7 @@ func TestMakePath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
viper.Set("RemovePathAccents", test.removeAccents)
|
viper.Set("removePathAccents", test.removeAccents)
|
||||||
p := NewPathSpecFromConfig(viper.GetViper())
|
p := NewPathSpecFromConfig(viper.GetViper())
|
||||||
output := p.MakePath(test.input)
|
output := p.MakePath(test.input)
|
||||||
if output != test.expected {
|
if output != test.expected {
|
||||||
|
@ -102,7 +102,7 @@ func TestMakePathSanitizedDisablePathToLower(t *testing.T) {
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
initCommonTestConfig()
|
initCommonTestConfig()
|
||||||
viper.Set("DisablePathToLower", true)
|
viper.Set("disablePathToLower", true)
|
||||||
p := NewPathSpecFromConfig(viper.GetViper())
|
p := NewPathSpecFromConfig(viper.GetViper())
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
@ -549,7 +549,7 @@ func TestAbsPathify(t *testing.T) {
|
||||||
for i, d := range data {
|
for i, d := range data {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
// todo see comment in AbsPathify
|
// todo see comment in AbsPathify
|
||||||
viper.Set("WorkingDir", d.workingDir)
|
viper.Set("workingDir", d.workingDir)
|
||||||
|
|
||||||
expected := AbsPathify(d.inPath)
|
expected := AbsPathify(d.inPath)
|
||||||
if d.expected != expected {
|
if d.expected != expected {
|
||||||
|
@ -559,7 +559,7 @@ func TestAbsPathify(t *testing.T) {
|
||||||
t.Logf("Running platform specific path tests for %s", runtime.GOOS)
|
t.Logf("Running platform specific path tests for %s", runtime.GOOS)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
for i, d := range windowsData {
|
for i, d := range windowsData {
|
||||||
viper.Set("WorkingDir", d.workingDir)
|
viper.Set("workingDir", d.workingDir)
|
||||||
|
|
||||||
expected := AbsPathify(d.inPath)
|
expected := AbsPathify(d.inPath)
|
||||||
if d.expected != expected {
|
if d.expected != expected {
|
||||||
|
@ -568,7 +568,7 @@ func TestAbsPathify(t *testing.T) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, d := range unixData {
|
for i, d := range unixData {
|
||||||
viper.Set("WorkingDir", d.workingDir)
|
viper.Set("workingDir", d.workingDir)
|
||||||
|
|
||||||
expected := AbsPathify(d.inPath)
|
expected := AbsPathify(d.inPath)
|
||||||
if d.expected != expected {
|
if d.expected != expected {
|
||||||
|
|
|
@ -17,15 +17,16 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/hugo/hugofs"
|
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pygmentsBin = "pygmentize"
|
const pygmentsBin = "pygmentize"
|
||||||
|
@ -62,8 +63,8 @@ func Highlight(code, lang, optsStr string) string {
|
||||||
|
|
||||||
fs := hugofs.Os()
|
fs := hugofs.Os()
|
||||||
|
|
||||||
ignoreCache := viper.GetBool("IgnoreCache")
|
ignoreCache := viper.GetBool("ignoreCache")
|
||||||
cacheDir := viper.GetString("CacheDir")
|
cacheDir := viper.GetString("cacheDir")
|
||||||
var cachefile string
|
var cachefile string
|
||||||
|
|
||||||
if !ignoreCache && cacheDir != "" {
|
if !ignoreCache && cacheDir != "" {
|
||||||
|
@ -198,17 +199,17 @@ func createOptionsString(options map[string]string) string {
|
||||||
func parseDefaultPygmentsOpts() (map[string]string, error) {
|
func parseDefaultPygmentsOpts() (map[string]string, error) {
|
||||||
|
|
||||||
options := make(map[string]string)
|
options := make(map[string]string)
|
||||||
err := parseOptions(options, viper.GetString("PygmentsOptions"))
|
err := parseOptions(options, viper.GetString("pygmentsOptions"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.IsSet("PygmentsStyle") {
|
if viper.IsSet("pygmentsStyle") {
|
||||||
options["style"] = viper.GetString("PygmentsStyle")
|
options["style"] = viper.GetString("pygmentsStyle")
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.IsSet("PygmentsUseClasses") {
|
if viper.IsSet("pygmentsUseClasses") {
|
||||||
if viper.GetBool("PygmentsUseClasses") {
|
if viper.GetBool("pygmentsUseClasses") {
|
||||||
options["noclasses"] = "false"
|
options["noclasses"] = "false"
|
||||||
} else {
|
} else {
|
||||||
options["noclasses"] = "true"
|
options["noclasses"] = "true"
|
||||||
|
|
|
@ -35,8 +35,8 @@ func TestParsePygmentsArgs(t *testing.T) {
|
||||||
{"style", "foo", false, false},
|
{"style", "foo", false, false},
|
||||||
} {
|
} {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
viper.Set("PygmentsStyle", this.pygmentsStyle)
|
viper.Set("pygmentsStyle", this.pygmentsStyle)
|
||||||
viper.Set("PygmentsUseClasses", this.pygmentsUseClasses)
|
viper.Set("pygmentsUseClasses", this.pygmentsUseClasses)
|
||||||
|
|
||||||
result1, err := parsePygmentsOpts(this.in)
|
result1, err := parsePygmentsOpts(this.in)
|
||||||
if b, ok := this.expect1.(bool); ok && !b {
|
if b, ok := this.expect1.(bool); ok && !b {
|
||||||
|
@ -72,14 +72,14 @@ func TestParseDefaultPygmentsArgs(t *testing.T) {
|
||||||
} {
|
} {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
|
|
||||||
viper.Set("PygmentsOptions", this.pygmentsOptions)
|
viper.Set("pygmentsOptions", this.pygmentsOptions)
|
||||||
|
|
||||||
if s, ok := this.pygmentsStyle.(string); ok {
|
if s, ok := this.pygmentsStyle.(string); ok {
|
||||||
viper.Set("PygmentsStyle", s)
|
viper.Set("pygmentsStyle", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if b, ok := this.pygmentsUseClasses.(bool); ok {
|
if b, ok := this.pygmentsUseClasses.(bool); ok {
|
||||||
viper.Set("PygmentsUseClasses", b)
|
viper.Set("pygmentsUseClasses", b)
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := parsePygmentsOpts(this.in)
|
result, err := parsePygmentsOpts(this.in)
|
||||||
|
|
|
@ -157,7 +157,7 @@ func (p *PathSpec) AbsURL(in string, addLanguage bool) string {
|
||||||
return in
|
return in
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL := viper.GetString("BaseURL")
|
baseURL := viper.GetString("baseURL")
|
||||||
if strings.HasPrefix(in, "/") {
|
if strings.HasPrefix(in, "/") {
|
||||||
p, err := url.Parse(baseURL)
|
p, err := url.Parse(baseURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -219,7 +219,7 @@ func IsAbsURL(path string) bool {
|
||||||
// RelURL creates a URL relative to the BaseURL root.
|
// RelURL creates a URL relative to the BaseURL root.
|
||||||
// Note: The result URL will not include the context root if canonifyURLs is enabled.
|
// Note: The result URL will not include the context root if canonifyURLs is enabled.
|
||||||
func (p *PathSpec) RelURL(in string, addLanguage bool) string {
|
func (p *PathSpec) RelURL(in string, addLanguage bool) string {
|
||||||
baseURL := viper.GetString("BaseURL")
|
baseURL := viper.GetString("baseURL")
|
||||||
canonifyURLs := p.canonifyURLs
|
canonifyURLs := p.canonifyURLs
|
||||||
if (!strings.HasPrefix(in, baseURL) && strings.HasPrefix(in, "http")) || strings.HasPrefix(in, "//") {
|
if (!strings.HasPrefix(in, baseURL) && strings.HasPrefix(in, "http")) || strings.HasPrefix(in, "//") {
|
||||||
return in
|
return in
|
||||||
|
|
|
@ -62,10 +62,10 @@ func TestAbsURL(t *testing.T) {
|
||||||
|
|
||||||
func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
|
func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
viper.Set("Multilingual", multilingual)
|
viper.Set("multilingual", multilingual)
|
||||||
viper.Set("CurrentContentLanguage", NewLanguage(lang))
|
viper.Set("currentContentLanguage", NewLanguage(lang))
|
||||||
viper.Set("DefaultContentLanguage", "en")
|
viper.Set("defaultContentLanguage", "en")
|
||||||
viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir)
|
viper.Set("defaultContentLanguageInSubdir", defaultInSubDir)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
|
@ -86,7 +86,7 @@ func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
viper.Set("BaseURL", test.baseURL)
|
viper.Set("baseURL", test.baseURL)
|
||||||
p := NewPathSpecFromConfig(viper.GetViper())
|
p := NewPathSpecFromConfig(viper.GetViper())
|
||||||
output := p.AbsURL(test.input, addLanguage)
|
output := p.AbsURL(test.input, addLanguage)
|
||||||
expected := test.expected
|
expected := test.expected
|
||||||
|
@ -136,10 +136,10 @@ func TestRelURL(t *testing.T) {
|
||||||
|
|
||||||
func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
|
func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
viper.Set("Multilingual", multilingual)
|
viper.Set("multilingual", multilingual)
|
||||||
viper.Set("CurrentContentLanguage", NewLanguage(lang))
|
viper.Set("currentContentLanguage", NewLanguage(lang))
|
||||||
viper.Set("DefaultContentLanguage", "en")
|
viper.Set("defaultContentLanguage", "en")
|
||||||
viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir)
|
viper.Set("defaultContentLanguageInSubdir", defaultInSubDir)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
|
@ -162,7 +162,7 @@ func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
viper.Set("BaseURL", test.baseURL)
|
viper.Set("baseURL", test.baseURL)
|
||||||
viper.Set("canonifyURLs", test.canonify)
|
viper.Set("canonifyURLs", test.canonify)
|
||||||
p := NewPathSpecFromConfig(viper.GetViper())
|
p := NewPathSpecFromConfig(viper.GetViper())
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ func InitFs(fs afero.Fs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initSourceDependencies() {
|
func initSourceDependencies() {
|
||||||
workingDir := viper.GetString("WorkingDir")
|
workingDir := viper.GetString("workingDir")
|
||||||
|
|
||||||
if workingDir != "" {
|
if workingDir != "" {
|
||||||
workingDirFs = afero.NewBasePathFs(afero.NewReadOnlyFs(sourceFs), workingDir).(*afero.BasePathFs)
|
workingDirFs = afero.NewBasePathFs(afero.NewReadOnlyFs(sourceFs), workingDir).(*afero.BasePathFs)
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
package hugofs
|
package hugofs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitDefault(t *testing.T) {
|
func TestInitDefault(t *testing.T) {
|
||||||
|
@ -71,7 +72,7 @@ func TestWorkingDir(t *testing.T) {
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
defer viper.Reset()
|
defer viper.Reset()
|
||||||
|
|
||||||
viper.Set("WorkingDir", "/a/b/")
|
viper.Set("workingDir", "/a/b/")
|
||||||
|
|
||||||
InitMemFs()
|
InitMemFs()
|
||||||
|
|
||||||
|
|
|
@ -53,57 +53,57 @@ func LoadGlobalConfig(relativeSourcePath, configFilename string) error {
|
||||||
|
|
||||||
func loadDefaultSettings() {
|
func loadDefaultSettings() {
|
||||||
viper.SetDefault("cleanDestinationDir", false)
|
viper.SetDefault("cleanDestinationDir", false)
|
||||||
viper.SetDefault("Watch", false)
|
viper.SetDefault("watch", false)
|
||||||
viper.SetDefault("MetaDataFormat", "toml")
|
viper.SetDefault("metaDataFormat", "toml")
|
||||||
viper.SetDefault("Disable404", false)
|
viper.SetDefault("disable404", false)
|
||||||
viper.SetDefault("DisableRSS", false)
|
viper.SetDefault("disableRSS", false)
|
||||||
viper.SetDefault("DisableSitemap", false)
|
viper.SetDefault("disableSitemap", false)
|
||||||
viper.SetDefault("DisableRobotsTXT", false)
|
viper.SetDefault("disableRobotsTXT", false)
|
||||||
viper.SetDefault("ContentDir", "content")
|
viper.SetDefault("contentDir", "content")
|
||||||
viper.SetDefault("LayoutDir", "layouts")
|
viper.SetDefault("layoutDir", "layouts")
|
||||||
viper.SetDefault("StaticDir", "static")
|
viper.SetDefault("staticDir", "static")
|
||||||
viper.SetDefault("ArchetypeDir", "archetypes")
|
viper.SetDefault("archetypeDir", "archetypes")
|
||||||
viper.SetDefault("PublishDir", "public")
|
viper.SetDefault("publishDir", "public")
|
||||||
viper.SetDefault("DataDir", "data")
|
viper.SetDefault("dataDir", "data")
|
||||||
viper.SetDefault("I18nDir", "i18n")
|
viper.SetDefault("i18nDir", "i18n")
|
||||||
viper.SetDefault("ThemesDir", "themes")
|
viper.SetDefault("themesDir", "themes")
|
||||||
viper.SetDefault("DefaultLayout", "post")
|
viper.SetDefault("defaultLayout", "post")
|
||||||
viper.SetDefault("BuildDrafts", false)
|
viper.SetDefault("buildDrafts", false)
|
||||||
viper.SetDefault("BuildFuture", false)
|
viper.SetDefault("buildFuture", false)
|
||||||
viper.SetDefault("BuildExpired", false)
|
viper.SetDefault("buildExpired", false)
|
||||||
viper.SetDefault("UglyURLs", false)
|
viper.SetDefault("uglyURLs", false)
|
||||||
viper.SetDefault("Verbose", false)
|
viper.SetDefault("verbose", false)
|
||||||
viper.SetDefault("IgnoreCache", false)
|
viper.SetDefault("ignoreCache", false)
|
||||||
viper.SetDefault("CanonifyURLs", false)
|
viper.SetDefault("canonifyURLs", false)
|
||||||
viper.SetDefault("RelativeURLs", false)
|
viper.SetDefault("relativeURLs", false)
|
||||||
viper.SetDefault("RemovePathAccents", false)
|
viper.SetDefault("removePathAccents", false)
|
||||||
viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"})
|
viper.SetDefault("taxonomies", map[string]string{"tag": "tags", "category": "categories"})
|
||||||
viper.SetDefault("Permalinks", make(PermalinkOverrides, 0))
|
viper.SetDefault("permalinks", make(PermalinkOverrides, 0))
|
||||||
viper.SetDefault("Sitemap", Sitemap{Priority: -1, Filename: "sitemap.xml"})
|
viper.SetDefault("sitemap", Sitemap{Priority: -1, Filename: "sitemap.xml"})
|
||||||
viper.SetDefault("DefaultExtension", "html")
|
viper.SetDefault("defaultExtension", "html")
|
||||||
viper.SetDefault("PygmentsStyle", "monokai")
|
viper.SetDefault("pygmentsStyle", "monokai")
|
||||||
viper.SetDefault("PygmentsUseClasses", false)
|
viper.SetDefault("pygmentsUseClasses", false)
|
||||||
viper.SetDefault("PygmentsCodeFences", false)
|
viper.SetDefault("pygmentsCodeFences", false)
|
||||||
viper.SetDefault("PygmentsOptions", "")
|
viper.SetDefault("pygmentsOptions", "")
|
||||||
viper.SetDefault("DisableLiveReload", false)
|
viper.SetDefault("disableLiveReload", false)
|
||||||
viper.SetDefault("PluralizeListTitles", true)
|
viper.SetDefault("pluralizeListTitles", true)
|
||||||
viper.SetDefault("PreserveTaxonomyNames", false)
|
viper.SetDefault("preserveTaxonomyNames", false)
|
||||||
viper.SetDefault("ForceSyncStatic", false)
|
viper.SetDefault("forceSyncStatic", false)
|
||||||
viper.SetDefault("FootnoteAnchorPrefix", "")
|
viper.SetDefault("footnoteAnchorPrefix", "")
|
||||||
viper.SetDefault("FootnoteReturnLinkContents", "")
|
viper.SetDefault("footnoteReturnLinkContents", "")
|
||||||
viper.SetDefault("NewContentEditor", "")
|
viper.SetDefault("newContentEditor", "")
|
||||||
viper.SetDefault("Paginate", 10)
|
viper.SetDefault("paginate", 10)
|
||||||
viper.SetDefault("PaginatePath", "page")
|
viper.SetDefault("paginatePath", "page")
|
||||||
viper.SetDefault("Blackfriday", helpers.NewBlackfriday(viper.GetViper()))
|
viper.SetDefault("blackfriday", helpers.NewBlackfriday(viper.GetViper()))
|
||||||
viper.SetDefault("RSSUri", "index.xml")
|
viper.SetDefault("rSSUri", "index.xml")
|
||||||
viper.SetDefault("SectionPagesMenu", "")
|
viper.SetDefault("sectionPagesMenu", "")
|
||||||
viper.SetDefault("DisablePathToLower", false)
|
viper.SetDefault("disablePathToLower", false)
|
||||||
viper.SetDefault("HasCJKLanguage", false)
|
viper.SetDefault("hasCJKLanguage", false)
|
||||||
viper.SetDefault("EnableEmoji", false)
|
viper.SetDefault("enableEmoji", false)
|
||||||
viper.SetDefault("PygmentsCodeFencesGuessSyntax", false)
|
viper.SetDefault("pygmentsCodeFencesGuessSyntax", false)
|
||||||
viper.SetDefault("UseModTimeAsFallback", false)
|
viper.SetDefault("useModTimeAsFallback", false)
|
||||||
viper.SetDefault("CurrentContentLanguage", helpers.NewDefaultLanguage())
|
viper.SetDefault("currentContentLanguage", helpers.NewDefaultLanguage())
|
||||||
viper.SetDefault("DefaultContentLanguage", "en")
|
viper.SetDefault("defaultContentLanguage", "en")
|
||||||
viper.SetDefault("DefaultContentLanguageInSubdir", false)
|
viper.SetDefault("defaultContentLanguageInSubdir", false)
|
||||||
viper.SetDefault("EnableMissingTranslationPlaceholders", false)
|
viper.SetDefault("enableMissingTranslationPlaceholders", false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,5 @@ func TestLoadGlobalConfig(t *testing.T) {
|
||||||
require.NoError(t, LoadGlobalConfig("", "hugo.toml"))
|
require.NoError(t, LoadGlobalConfig("", "hugo.toml"))
|
||||||
assert.Equal(t, "side", helpers.Config().GetString("paginatePath"))
|
assert.Equal(t, "side", helpers.Config().GetString("paginatePath"))
|
||||||
// default
|
// default
|
||||||
assert.Equal(t, "layouts", viper.GetString("LayoutDir"))
|
assert.Equal(t, "layouts", viper.GetString("layoutDir"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ func TestShortcodeHighlight(t *testing.T) {
|
||||||
if !helpers.HasPygments() {
|
if !helpers.HasPygments() {
|
||||||
t.Skip("Skip test as Pygments is not installed")
|
t.Skip("Skip test as Pygments is not installed")
|
||||||
}
|
}
|
||||||
viper.Set("PygmentsStyle", "bw")
|
viper.Set("pygmentsStyle", "bw")
|
||||||
viper.Set("PygmentsUseClasses", false)
|
viper.Set("pygmentsUseClasses", false)
|
||||||
|
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
in, expected string
|
in, expected string
|
||||||
|
@ -311,7 +311,7 @@ func TestShortcodeTweet(t *testing.T) {
|
||||||
templ.Lookup("").Funcs(tweetFuncMap)
|
templ.Lookup("").Funcs(tweetFuncMap)
|
||||||
|
|
||||||
p, _ := pageFromString(simplePage, "simple.md")
|
p, _ := pageFromString(simplePage, "simple.md")
|
||||||
cacheFileID := viper.GetString("CacheDir") + url.QueryEscape("https://api.twitter.com/1/statuses/oembed.json?id=666616452582129664")
|
cacheFileID := viper.GetString("cacheDir") + url.QueryEscape("https://api.twitter.com/1/statuses/oembed.json?id=666616452582129664")
|
||||||
defer os.Remove(cacheFileID)
|
defer os.Remove(cacheFileID)
|
||||||
output, err := HandleShortcodes(this.in, p, templ)
|
output, err := HandleShortcodes(this.in, p, templ)
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ func commonConvert(p *Page, t tpl.Template) HandledResult {
|
||||||
|
|
||||||
// TODO(bep) these page handlers need to be re-evaluated, as it is hard to
|
// TODO(bep) these page handlers need to be re-evaluated, as it is hard to
|
||||||
// process a page in isolation. See the new preRender func.
|
// process a page in isolation. See the new preRender func.
|
||||||
if viper.GetBool("EnableEmoji") {
|
if viper.GetBool("enableEmoji") {
|
||||||
p.rawContent = helpers.Emojify(p.rawContent)
|
p.rawContent = helpers.Emojify(p.rawContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func TestDefaultHandler(t *testing.T) {
|
||||||
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
|
|
|
@ -73,7 +73,7 @@ func NewHugoSitesFromConfiguration() (*HugoSites, error) {
|
||||||
|
|
||||||
func createSitesFromConfig() ([]*Site, error) {
|
func createSitesFromConfig() ([]*Site, error) {
|
||||||
var sites []*Site
|
var sites []*Site
|
||||||
multilingual := viper.GetStringMap("Languages")
|
multilingual := viper.GetStringMap("languages")
|
||||||
if len(multilingual) == 0 {
|
if len(multilingual) == 0 {
|
||||||
sites = append(sites, newSite(helpers.NewDefaultLanguage()))
|
sites = append(sites, newSite(helpers.NewDefaultLanguage()))
|
||||||
}
|
}
|
||||||
|
@ -339,12 +339,12 @@ func (h *HugoSites) render() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("DisableSitemap") {
|
if viper.GetBool("disableSitemap") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bep) DRY
|
// TODO(bep) DRY
|
||||||
sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap"))
|
sitemapDefault := parseSitemap(viper.GetStringMap("sitemap"))
|
||||||
|
|
||||||
s := h.Sites[0]
|
s := h.Sites[0]
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func testCommonResetState() {
|
||||||
loadDefaultSettings()
|
loadDefaultSettings()
|
||||||
|
|
||||||
// Default is false, but true is easier to use as default in tests
|
// Default is false, but true is easier to use as default in tests
|
||||||
viper.Set("DefaultContentLanguageInSubdir", true)
|
viper.Set("defaultContentLanguageInSubdir", true)
|
||||||
|
|
||||||
if err := hugofs.Source().Mkdir("content", 0755); err != nil {
|
if err := hugofs.Source().Mkdir("content", 0755); err != nil {
|
||||||
panic("Content folder creation failed.")
|
panic("Content folder creation failed.")
|
||||||
|
@ -56,7 +56,7 @@ func TestMultiSitesMainLangInRoot(t *testing.T) {
|
||||||
|
|
||||||
func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
|
func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir)
|
viper.Set("defaultContentLanguageInSubdir", defaultInSubDir)
|
||||||
siteConfig := testSiteConfig{DefaultContentLanguage: "fr"}
|
siteConfig := testSiteConfig{DefaultContentLanguage: "fr"}
|
||||||
|
|
||||||
sites := createMultiTestSites(t, siteConfig, multiSiteTOMLConfigTemplate)
|
sites := createMultiTestSites(t, siteConfig, multiSiteTOMLConfigTemplate)
|
||||||
|
@ -155,7 +155,7 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func replaceDefaultContentLanguageValue(value string, defaultInSubDir bool) string {
|
func replaceDefaultContentLanguageValue(value string, defaultInSubDir bool) string {
|
||||||
replace := viper.GetString("DefaultContentLanguage") + "/"
|
replace := viper.GetString("defaultContentLanguage") + "/"
|
||||||
if !defaultInSubDir {
|
if !defaultInSubDir {
|
||||||
value = strings.Replace(value, replace, "", 1)
|
value = strings.Replace(value, replace, "", 1)
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ title = "Svenska"
|
||||||
|
|
||||||
func TestChangeDefaultLanguage(t *testing.T) {
|
func TestChangeDefaultLanguage(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
viper.Set("DefaultContentLanguageInSubdir", false)
|
viper.Set("defaultContentLanguageInSubdir", false)
|
||||||
|
|
||||||
sites := createMultiTestSites(t, testSiteConfig{DefaultContentLanguage: "fr"}, multiSiteTOMLConfigTemplate)
|
sites := createMultiTestSites(t, testSiteConfig{DefaultContentLanguage: "fr"}, multiSiteTOMLConfigTemplate)
|
||||||
cfg := BuildCfg{}
|
cfg := BuildCfg{}
|
||||||
|
@ -771,14 +771,14 @@ var tocPageWithShortcodesInHeadingsExpected = `<nav id="TableOfContents">
|
||||||
</nav>`
|
</nav>`
|
||||||
|
|
||||||
var multiSiteTOMLConfigTemplate = `
|
var multiSiteTOMLConfigTemplate = `
|
||||||
DefaultExtension = "html"
|
defaultExtension = "html"
|
||||||
baseurl = "http://example.com/blog"
|
baseURL = "http://example.com/blog"
|
||||||
DisableSitemap = false
|
disableSitemap = false
|
||||||
DisableRSS = false
|
disableRSS = false
|
||||||
RSSUri = "index.xml"
|
rssURI = "index.xml"
|
||||||
|
|
||||||
paginate = 1
|
paginate = 1
|
||||||
DefaultContentLanguage = "{{ .DefaultContentLanguage }}"
|
defaultContentLanguage = "{{ .DefaultContentLanguage }}"
|
||||||
|
|
||||||
[permalinks]
|
[permalinks]
|
||||||
other = "/somewhere/else/:filename"
|
other = "/somewhere/else/:filename"
|
||||||
|
@ -830,14 +830,14 @@ lag = "lag"
|
||||||
`
|
`
|
||||||
|
|
||||||
var multiSiteYAMLConfig = `
|
var multiSiteYAMLConfig = `
|
||||||
DefaultExtension: "html"
|
defaultExtension: "html"
|
||||||
baseurl: "http://example.com/blog"
|
baseURL: "http://example.com/blog"
|
||||||
DisableSitemap: false
|
disableSitemap: false
|
||||||
DisableRSS: false
|
disableRSS: false
|
||||||
RSSUri: "index.xml"
|
rssURI: "index.xml"
|
||||||
|
|
||||||
paginate: 1
|
paginate: 1
|
||||||
DefaultContentLanguage: "fr"
|
defaultContentLanguage: "fr"
|
||||||
|
|
||||||
permalinks:
|
permalinks:
|
||||||
other: "/somewhere/else/:filename"
|
other: "/somewhere/else/:filename"
|
||||||
|
@ -890,13 +890,13 @@ Languages:
|
||||||
|
|
||||||
var multiSiteJSONConfig = `
|
var multiSiteJSONConfig = `
|
||||||
{
|
{
|
||||||
"DefaultExtension": "html",
|
"defaultExtension": "html",
|
||||||
"baseurl": "http://example.com/blog",
|
"baseURL": "http://example.com/blog",
|
||||||
"DisableSitemap": false,
|
"disableSitemap": false,
|
||||||
"DisableRSS": false,
|
"disableRSS": false,
|
||||||
"RSSUri": "index.xml",
|
"rssURI": "index.xml",
|
||||||
"paginate": 1,
|
"paginate": 1,
|
||||||
"DefaultContentLanguage": "fr",
|
"defaultContentLanguage": "fr",
|
||||||
"permalinks": {
|
"permalinks": {
|
||||||
"other": "/somewhere/else/:filename"
|
"other": "/somewhere/else/:filename"
|
||||||
},
|
},
|
||||||
|
@ -1080,7 +1080,7 @@ publishdate: "2000-01-05"
|
||||||
---
|
---
|
||||||
# doc4
|
# doc4
|
||||||
*du contenu francophone*
|
*du contenu francophone*
|
||||||
NOTE: should use the DefaultContentLanguage and mark this doc as 'fr'.
|
NOTE: should use the defaultContentLanguage and mark this doc as 'fr'.
|
||||||
NOTE: doesn't have any corresponding translation in 'en'
|
NOTE: doesn't have any corresponding translation in 'en'
|
||||||
`)},
|
`)},
|
||||||
{Name: filepath.FromSlash("other/doc5.fr.md"), Content: []byte(`---
|
{Name: filepath.FromSlash("other/doc5.fr.md"), Content: []byte(`---
|
||||||
|
|
|
@ -376,7 +376,7 @@ func TestMenuWithUnicodeURLs(t *testing.T) {
|
||||||
func doTestMenuWithUnicodeURLs(t *testing.T, canonifyURLs bool) {
|
func doTestMenuWithUnicodeURLs(t *testing.T, canonifyURLs bool) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("CanonifyURLs", canonifyURLs)
|
viper.Set("canonifyURLs", canonifyURLs)
|
||||||
|
|
||||||
s := setupMenuTests(t, menuPageSources)
|
s := setupMenuTests(t, menuPageSources)
|
||||||
|
|
||||||
|
@ -398,12 +398,12 @@ func TestSectionPagesMenu(t *testing.T) {
|
||||||
doTestSectionPagesMenu(false, t)
|
doTestSectionPagesMenu(false, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) {
|
func doTestSectionPagesMenu(canonifyURLs bool, t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("SectionPagesMenu", "spm")
|
viper.Set("sectionPagesMenu", "spm")
|
||||||
|
|
||||||
viper.Set("CanonifyURLs", canonifyUrls)
|
viper.Set("canonifyURLs", canonifyURLs)
|
||||||
s := setupMenuTests(t, menuPageSectionsSources)
|
s := setupMenuTests(t, menuPageSectionsSources)
|
||||||
|
|
||||||
assert.Equal(t, 3, len(s.Sections))
|
assert.Equal(t, 3, len(s.Sections))
|
||||||
|
@ -459,7 +459,7 @@ func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) {
|
||||||
func TestTaxonomyNodeMenu(t *testing.T) {
|
func TestTaxonomyNodeMenu(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("CanonifyURLs", true)
|
viper.Set("canonifyURLs", true)
|
||||||
s := setupMenuTests(t, menuPageSources)
|
s := setupMenuTests(t, menuPageSources)
|
||||||
|
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
|
@ -544,8 +544,8 @@ func TestMenuSortByN(t *testing.T) {
|
||||||
func TestHomeNodeMenu(t *testing.T) {
|
func TestHomeNodeMenu(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("CanonifyURLs", true)
|
viper.Set("canonifyURLs", true)
|
||||||
viper.Set("UglyURLs", true)
|
viper.Set("uglyURLs", true)
|
||||||
|
|
||||||
s := setupMenuTests(t, menuPageSources)
|
s := setupMenuTests(t, menuPageSources)
|
||||||
|
|
||||||
|
@ -660,11 +660,11 @@ func setupTestMenuState(t *testing.T) {
|
||||||
menus, err := tomlToMap(confMenu1)
|
menus, err := tomlToMap(confMenu1)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to Read menus: %v", err)
|
t.Fatalf("Unable to read menus: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("menu", menus["menu"])
|
viper.Set("menu", menus["menu"])
|
||||||
viper.Set("baseurl", "http://foo.local/Zoo/")
|
viper.Set("baseURL", "http://foo.local/Zoo/")
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupMenuTests(t *testing.T, pageSources []source.ByteSource) *Site {
|
func setupMenuTests(t *testing.T, pageSources []source.ByteSource) *Site {
|
||||||
|
|
|
@ -588,10 +588,10 @@ func (p *Page) permalink() (*url.URL, error) {
|
||||||
// fmt.Printf("have a section override for %q in section %s → %s\n", p.Title, p.Section, permalink)
|
// fmt.Printf("have a section override for %q in section %s → %s\n", p.Title, p.Section, permalink)
|
||||||
} else {
|
} else {
|
||||||
if len(pSlug) > 0 {
|
if len(pSlug) > 0 {
|
||||||
permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, p.Slug+"."+p.Extension()))
|
permalink = helpers.URLPrep(viper.GetBool("uglyURLs"), path.Join(dir, p.Slug+"."+p.Extension()))
|
||||||
} else {
|
} else {
|
||||||
t := p.Source.TranslationBaseName()
|
t := p.Source.TranslationBaseName()
|
||||||
permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension())))
|
permalink = helpers.URLPrep(viper.GetBool("uglyURLs"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ func (p *Page) Extension() string {
|
||||||
if p.extension != "" {
|
if p.extension != "" {
|
||||||
return p.extension
|
return p.extension
|
||||||
}
|
}
|
||||||
return viper.GetString("DefaultExtension")
|
return viper.GetString("defaultExtension")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllTranslations returns all translations, including the current Page.
|
// AllTranslations returns all translations, including the current Page.
|
||||||
|
@ -637,8 +637,8 @@ func (p *Page) LinkTitle() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page) shouldBuild() bool {
|
func (p *Page) shouldBuild() bool {
|
||||||
return shouldBuild(viper.GetBool("BuildFuture"), viper.GetBool("BuildExpired"),
|
return shouldBuild(viper.GetBool("buildFuture"), viper.GetBool("buildExpired"),
|
||||||
viper.GetBool("BuildDrafts"), p.Draft, p.PublishDate, p.ExpiryDate)
|
viper.GetBool("buildDrafts"), p.Draft, p.PublishDate, p.ExpiryDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldBuild(buildFuture bool, buildExpired bool, buildDrafts bool, Draft bool,
|
func shouldBuild(buildFuture bool, buildExpired bool, buildDrafts bool, Draft bool,
|
||||||
|
@ -697,7 +697,7 @@ func (p *Page) RelPermalink() (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("CanonifyURLs") {
|
if viper.GetBool("canonifyURLs") {
|
||||||
// replacements for relpermalink with baseURL on the form http://myhost.com/sub/ will fail later on
|
// replacements for relpermalink with baseURL on the form http://myhost.com/sub/ will fail later on
|
||||||
// have to return the URL relative from baseURL
|
// have to return the URL relative from baseURL
|
||||||
relpath, err := helpers.GetRelativePath(link.String(), string(p.Site.BaseURL))
|
relpath, err := helpers.GetRelativePath(link.String(), string(p.Site.BaseURL))
|
||||||
|
@ -842,8 +842,8 @@ func (p *Page) update(f interface{}) error {
|
||||||
p.Draft = !*published
|
p.Draft = !*published
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Date.IsZero() && viper.GetBool("UseModTimeAsFallback") {
|
if p.Date.IsZero() && viper.GetBool("useModTimeAsFallback") {
|
||||||
fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), p.File.Path()))
|
fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("contentDir")), p.File.Path()))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
p.Date = fi.ModTime()
|
p.Date = fi.ModTime()
|
||||||
}
|
}
|
||||||
|
@ -855,7 +855,7 @@ func (p *Page) update(f interface{}) error {
|
||||||
|
|
||||||
if isCJKLanguage != nil {
|
if isCJKLanguage != nil {
|
||||||
p.isCJKLanguage = *isCJKLanguage
|
p.isCJKLanguage = *isCJKLanguage
|
||||||
} else if viper.GetBool("HasCJKLanguage") {
|
} else if viper.GetBool("hasCJKLanguage") {
|
||||||
if cjk.Match(p.rawContent) {
|
if cjk.Match(p.rawContent) {
|
||||||
p.isCJKLanguage = true
|
p.isCJKLanguage = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,10 +59,10 @@ func TestPermalink(t *testing.T) {
|
||||||
{"x/y/z/boofar.md", "", "", "/z/y/q/", false, false, "/z/y/q/", "/z/y/q/"},
|
{"x/y/z/boofar.md", "", "", "/z/y/q/", false, false, "/z/y/q/", "/z/y/q/"},
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
viper.Set("uglyurls", test.uglyURLs)
|
viper.Set("uglyURLs", test.uglyURLs)
|
||||||
viper.Set("canonifyurls", test.canonifyURLs)
|
viper.Set("canonifyURLs", test.canonifyURLs)
|
||||||
info := newSiteInfo(siteBuilderCfg{baseURL: string(test.base), language: helpers.NewDefaultLanguage()})
|
info := newSiteInfo(siteBuilderCfg{baseURL: string(test.base), language: helpers.NewDefaultLanguage()})
|
||||||
|
|
||||||
p := &Page{
|
p := &Page{
|
||||||
|
|
|
@ -830,7 +830,7 @@ func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage(t *testing.T) {
|
||||||
|
|
||||||
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
viper.Set("HasCJKLanguage", true)
|
viper.Set("hasCJKLanguage", true)
|
||||||
|
|
||||||
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
||||||
p := pages[0]
|
p := pages[0]
|
||||||
|
@ -844,7 +844,7 @@ func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) {
|
||||||
func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("HasCJKLanguage", true)
|
viper.Set("hasCJKLanguage", true)
|
||||||
|
|
||||||
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
||||||
p := pages[0]
|
p := pages[0]
|
||||||
|
@ -863,7 +863,7 @@ func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) {
|
||||||
|
|
||||||
func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
|
func TestWordCountWithIsCJKLanguageFalse(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
viper.Set("HasCJKLanguage", true)
|
viper.Set("hasCJKLanguage", true)
|
||||||
|
|
||||||
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
assertFunc := func(t *testing.T, ext string, pages Pages) {
|
||||||
p := pages[0]
|
p := pages[0]
|
||||||
|
@ -1099,7 +1099,7 @@ func TestSliceToLower(t *testing.T) {
|
||||||
func TestPagePaths(t *testing.T) {
|
func TestPagePaths(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
siteParmalinksSetting := PermalinkOverrides{
|
siteParmalinksSetting := PermalinkOverrides{
|
||||||
"post": ":year/:month/:day/:title/",
|
"post": ":year/:month/:day/:title/",
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ func doTestPagerNoPages(t *testing.T, paginator *paginator) {
|
||||||
func TestPaginationURLFactory(t *testing.T) {
|
func TestPaginationURLFactory(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("PaginatePath", "zoo")
|
viper.Set("paginatePath", "zoo")
|
||||||
unicode := newPaginationURLFactory("новости проекта")
|
unicode := newPaginationURLFactory("новости проекта")
|
||||||
fooBar := newPaginationURLFactory("foo", "bar")
|
fooBar := newPaginationURLFactory("foo", "bar")
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestRobotsTXTOutput(t *testing.T) {
|
||||||
|
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub/")
|
viper.Set("baseURL", "http://auth/bub/")
|
||||||
viper.Set("enableRobotsTXT", true)
|
viper.Set("enableRobotsTXT", true)
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
|
@ -54,6 +54,6 @@ func TestRobotsTXTOutput(t *testing.T) {
|
||||||
|
|
||||||
robots := helpers.ReaderToBytes(robotsFile)
|
robots := helpers.ReaderToBytes(robotsFile)
|
||||||
if !bytes.HasPrefix(robots, []byte("User-agent: Googlebot")) {
|
if !bytes.HasPrefix(robots, []byte("User-agent: Googlebot")) {
|
||||||
t.Errorf("Robots file should start with 'User-agentL Googlebot'. %s", robots)
|
t.Errorf("Robots file should start with 'User-agent: Googlebot'. %s", robots)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ func TestRSSOutput(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
rssURI := "public/customrss.xml"
|
rssURI := "public/customrss.xml"
|
||||||
viper.Set("baseurl", "http://auth/bub/")
|
viper.Set("baseURL", "http://auth/bub/")
|
||||||
viper.Set("RSSUri", rssURI)
|
viper.Set("rssURI", rssURI)
|
||||||
|
|
||||||
for _, s := range weightedSources {
|
for _, s := range weightedSources {
|
||||||
writeSource(t, filepath.Join("content", s.Name), string(s.Content))
|
writeSource(t, filepath.Join("content", s.Name), string(s.Content))
|
||||||
|
|
|
@ -305,8 +305,8 @@ func TestHighlight(t *testing.T) {
|
||||||
if !helpers.HasPygments() {
|
if !helpers.HasPygments() {
|
||||||
t.Skip("Skip test as Pygments is not installed")
|
t.Skip("Skip test as Pygments is not installed")
|
||||||
}
|
}
|
||||||
viper.Set("PygmentsStyle", "bw")
|
viper.Set("pygmentsStyle", "bw")
|
||||||
viper.Set("PygmentsUseClasses", false)
|
viper.Set("pygmentsUseClasses", false)
|
||||||
|
|
||||||
templ := tpl.New()
|
templ := tpl.New()
|
||||||
|
|
||||||
|
@ -455,14 +455,14 @@ func TestShortcodesInSite(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
baseURL := "http://foo/bar"
|
baseURL := "http://foo/bar"
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("DefaultContentLanguage", "en")
|
viper.Set("defaultContentLanguage", "en")
|
||||||
viper.Set("baseurl", baseURL)
|
viper.Set("baseURL", baseURL)
|
||||||
viper.Set("UglyURLs", false)
|
viper.Set("uglyURLs", false)
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
|
|
||||||
viper.Set("pygmentsuseclasses", true)
|
viper.Set("pygmentsUseClasses", true)
|
||||||
viper.Set("pygmentscodefences", true)
|
viper.Set("pygmentsCodefences", true)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
contentPath string
|
contentPath string
|
||||||
|
|
110
hugolib/site.go
110
hugolib/site.go
|
@ -819,8 +819,8 @@ func (s *Site) setupPrevNext() {
|
||||||
|
|
||||||
func (s *Site) setCurrentLanguageConfig() error {
|
func (s *Site) setCurrentLanguageConfig() error {
|
||||||
// There are sadly some global template funcs etc. that need the language information.
|
// There are sadly some global template funcs etc. that need the language information.
|
||||||
viper.Set("Multilingual", s.multilingualEnabled())
|
viper.Set("multilingual", s.multilingualEnabled())
|
||||||
viper.Set("CurrentContentLanguage", s.Language)
|
viper.Set("currentContentLanguage", s.Language)
|
||||||
// Cache the current config.
|
// Cache the current config.
|
||||||
helpers.InitConfigProviderForCurrentContentLanguage()
|
helpers.InitConfigProviderForCurrentContentLanguage()
|
||||||
return tpl.SetTranslateLang(s.Language)
|
return tpl.SetTranslateLang(s.Language)
|
||||||
|
@ -886,7 +886,7 @@ func (s *Site) initialize() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
staticDir := helpers.AbsPathify(viper.GetString("StaticDir") + "/")
|
staticDir := helpers.AbsPathify(viper.GetString("staticDir") + "/")
|
||||||
|
|
||||||
s.Source = &source.Filesystem{
|
s.Source = &source.Filesystem{
|
||||||
AvoidPaths: []string{staticDir},
|
AvoidPaths: []string{staticDir},
|
||||||
|
@ -907,7 +907,7 @@ func (s *SiteInfo) HomeAbsURL() string {
|
||||||
|
|
||||||
// SitemapAbsURL is a convenience method giving the absolute URL to the sitemap.
|
// SitemapAbsURL is a convenience method giving the absolute URL to the sitemap.
|
||||||
func (s *SiteInfo) SitemapAbsURL() string {
|
func (s *SiteInfo) SitemapAbsURL() string {
|
||||||
sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap"))
|
sitemapDefault := parseSitemap(viper.GetStringMap("sitemap"))
|
||||||
p := s.HomeAbsURL()
|
p := s.HomeAbsURL()
|
||||||
if !strings.HasSuffix(p, "/") {
|
if !strings.HasSuffix(p, "/") {
|
||||||
p += "/"
|
p += "/"
|
||||||
|
@ -930,12 +930,12 @@ func (s *Site) initializeSiteInfo() {
|
||||||
params := lang.Params()
|
params := lang.Params()
|
||||||
|
|
||||||
permalinks := make(PermalinkOverrides)
|
permalinks := make(PermalinkOverrides)
|
||||||
for k, v := range viper.GetStringMapString("Permalinks") {
|
for k, v := range viper.GetStringMapString("permalinks") {
|
||||||
permalinks[k] = pathPattern(v)
|
permalinks[k] = pathPattern(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultContentInSubDir := viper.GetBool("DefaultContentLanguageInSubdir")
|
defaultContentInSubDir := viper.GetBool("defaultContentLanguageInSubdir")
|
||||||
defaultContentLanguage := viper.GetString("DefaultContentLanguage")
|
defaultContentLanguage := viper.GetString("defaultContentLanguage")
|
||||||
|
|
||||||
languagePrefix := ""
|
languagePrefix := ""
|
||||||
if s.multilingualEnabled() && (defaultContentInSubDir || lang.Lang != defaultContentLanguage) {
|
if s.multilingualEnabled() && (defaultContentInSubDir || lang.Lang != defaultContentLanguage) {
|
||||||
|
@ -948,22 +948,22 @@ func (s *Site) initializeSiteInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Info = SiteInfo{
|
s.Info = SiteInfo{
|
||||||
BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))),
|
BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("baseURL"))),
|
||||||
Title: lang.GetString("Title"),
|
Title: lang.GetString("title"),
|
||||||
Author: lang.GetStringMap("author"),
|
Author: lang.GetStringMap("author"),
|
||||||
Social: lang.GetStringMapString("social"),
|
Social: lang.GetStringMapString("social"),
|
||||||
LanguageCode: lang.GetString("languagecode"),
|
LanguageCode: lang.GetString("languageCode"),
|
||||||
Copyright: lang.GetString("copyright"),
|
Copyright: lang.GetString("copyright"),
|
||||||
DisqusShortname: lang.GetString("DisqusShortname"),
|
DisqusShortname: lang.GetString("disqusShortname"),
|
||||||
multilingual: multilingual,
|
multilingual: multilingual,
|
||||||
Language: lang,
|
Language: lang,
|
||||||
LanguagePrefix: languagePrefix,
|
LanguagePrefix: languagePrefix,
|
||||||
Languages: languages,
|
Languages: languages,
|
||||||
defaultContentLanguageInSubdir: defaultContentInSubDir,
|
defaultContentLanguageInSubdir: defaultContentInSubDir,
|
||||||
GoogleAnalytics: lang.GetString("GoogleAnalytics"),
|
GoogleAnalytics: lang.GetString("googleAnalytics"),
|
||||||
BuildDrafts: viper.GetBool("BuildDrafts"),
|
BuildDrafts: viper.GetBool("buildDrafts"),
|
||||||
canonifyURLs: viper.GetBool("CanonifyURLs"),
|
canonifyURLs: viper.GetBool("canonifyURLs"),
|
||||||
preserveTaxonomyNames: lang.GetBool("PreserveTaxonomyNames"),
|
preserveTaxonomyNames: lang.GetBool("preserveTaxonomyNames"),
|
||||||
AllPages: &s.AllPages,
|
AllPages: &s.AllPages,
|
||||||
Pages: &s.Pages,
|
Pages: &s.Pages,
|
||||||
rawAllPages: &s.rawAllPages,
|
rawAllPages: &s.rawAllPages,
|
||||||
|
@ -984,14 +984,14 @@ func (s *Site) hasTheme() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) dataDir() string {
|
func (s *Site) dataDir() string {
|
||||||
return viper.GetString("DataDir")
|
return viper.GetString("dataDir")
|
||||||
}
|
}
|
||||||
func (s *Site) absDataDir() string {
|
func (s *Site) absDataDir() string {
|
||||||
return helpers.AbsPathify(s.dataDir())
|
return helpers.AbsPathify(s.dataDir())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) i18nDir() string {
|
func (s *Site) i18nDir() string {
|
||||||
return viper.GetString("I18nDir")
|
return viper.GetString("i18nDir")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) absI18nDir() string {
|
func (s *Site) absI18nDir() string {
|
||||||
|
@ -1043,7 +1043,7 @@ func (s *Site) absThemeDir() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) layoutDir() string {
|
func (s *Site) layoutDir() string {
|
||||||
return viper.GetString("LayoutDir")
|
return viper.GetString("layoutDir")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) absLayoutDir() string {
|
func (s *Site) absLayoutDir() string {
|
||||||
|
@ -1069,7 +1069,7 @@ func (s *Site) getThemeLayoutDir(path string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) absContentDir() string {
|
func (s *Site) absContentDir() string {
|
||||||
return helpers.AbsPathify(viper.GetString("ContentDir"))
|
return helpers.AbsPathify(viper.GetString("contentDir"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) isContentDirEvent(e fsnotify.Event) bool {
|
func (s *Site) isContentDirEvent(e fsnotify.Event) bool {
|
||||||
|
@ -1105,7 +1105,7 @@ func getRealDir(base, path string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) absPublishDir() string {
|
func (s *Site) absPublishDir() string {
|
||||||
return helpers.AbsPathify(viper.GetString("PublishDir"))
|
return helpers.AbsPathify(viper.GetString("publishDir"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) checkDirectories() (err error) {
|
func (s *Site) checkDirectories() (err error) {
|
||||||
|
@ -1756,7 +1756,7 @@ func (s *Site) renderTaxonomiesLists(prepare bool) error {
|
||||||
|
|
||||||
go errorCollator(results, errs)
|
go errorCollator(results, errs)
|
||||||
|
|
||||||
taxonomies := s.Language.GetStringMapString("Taxonomies")
|
taxonomies := s.Language.GetStringMapString("taxonomies")
|
||||||
for singular, plural := range taxonomies {
|
for singular, plural := range taxonomies {
|
||||||
for key, pages := range s.Taxonomies[plural] {
|
for key, pages := range s.Taxonomies[plural] {
|
||||||
taxes <- taxRenderInfo{key, pages, singular, plural}
|
taxes <- taxRenderInfo{key, pages, singular, plural}
|
||||||
|
@ -1832,7 +1832,7 @@ func taxonomyRenderer(prepare bool, s *Site, taxes <-chan taxRenderInfo, results
|
||||||
[]string{"taxonomy/" + t.singular + ".html", "indexes/" + t.singular + ".html", "_default/taxonomy.html", "_default/list.html"})
|
[]string{"taxonomy/" + t.singular + ".html", "indexes/" + t.singular + ".html", "_default/taxonomy.html", "_default/list.html"})
|
||||||
|
|
||||||
dest := base
|
dest := base
|
||||||
if viper.GetBool("UglyURLs") {
|
if viper.GetBool("uglyURLs") {
|
||||||
dest = helpers.Uglify(baseWithLanguagePrefix + ".html")
|
dest = helpers.Uglify(baseWithLanguagePrefix + ".html")
|
||||||
} else {
|
} else {
|
||||||
dest = helpers.PrettifyPath(baseWithLanguagePrefix + "/index.html")
|
dest = helpers.PrettifyPath(baseWithLanguagePrefix + "/index.html")
|
||||||
|
@ -1880,16 +1880,16 @@ func taxonomyRenderer(prepare bool, s *Site, taxes <-chan taxRenderInfo, results
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viper.GetBool("DisableRSS") {
|
if !viper.GetBool("disableRSS") {
|
||||||
// XML Feed
|
// XML Feed
|
||||||
rssNode := s.newNode(fmt.Sprintf("%s-%s-rss", t.plural, t.key))
|
rssNode := s.newNode(fmt.Sprintf("%s-%s-rss", t.plural, t.key))
|
||||||
rssuri := viper.GetString("RSSUri")
|
rssURI := viper.GetString("rssURI")
|
||||||
s.setURLs(rssNode, base+"/"+rssuri)
|
s.setURLs(rssNode, base+"/"+rssURI)
|
||||||
rssNode.Data = n.Data
|
rssNode.Data = n.Data
|
||||||
|
|
||||||
rssLayouts := []string{"taxonomy/" + t.singular + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}
|
rssLayouts := []string{"taxonomy/" + t.singular + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}
|
||||||
|
|
||||||
if err := s.renderAndWriteXML("taxonomy "+t.singular+" rss", baseWithLanguagePrefix+"/"+rssuri, rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
if err := s.renderAndWriteXML("taxonomy "+t.singular+" rss", baseWithLanguagePrefix+"/"+rssURI, rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
||||||
results <- err
|
results <- err
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1936,7 +1936,7 @@ func (s *Site) newSectionListNode(prepare bool, sectionName, section string, dat
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionName = helpers.FirstUpper(sectionName)
|
sectionName = helpers.FirstUpper(sectionName)
|
||||||
if viper.GetBool("PluralizeListTitles") {
|
if viper.GetBool("pluralizeListTitles") {
|
||||||
n.Title = inflect.Pluralize(sectionName)
|
n.Title = inflect.Pluralize(sectionName)
|
||||||
} else {
|
} else {
|
||||||
n.Title = sectionName
|
n.Title = sectionName
|
||||||
|
@ -2012,13 +2012,13 @@ func (s *Site) renderSectionLists(prepare bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viper.GetBool("DisableRSS") && section != "" {
|
if !viper.GetBool("disableRSS") && section != "" {
|
||||||
// XML Feed
|
// XML Feed
|
||||||
rssuri := viper.GetString("RSSUri")
|
rssURI := viper.GetString("rssURI")
|
||||||
rssNode := s.newSectionListNode(true, sectionName+"-rss", section, data, 0)
|
rssNode := s.newSectionListNode(true, sectionName+"-rss", section, data, 0)
|
||||||
s.setURLs(rssNode, section+"/"+rssuri)
|
s.setURLs(rssNode, section+"/"+rssURI)
|
||||||
rssLayouts := []string{"section/" + section + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}
|
rssLayouts := []string{"section/" + section + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}
|
||||||
if err := s.renderAndWriteXML("section "+section+" rss", rssNode.addLangPathPrefix(section+"/"+rssuri), rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
if err := s.renderAndWriteXML("section "+section+" rss", rssNode.addLangPathPrefix(section+"/"+rssURI), rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2076,10 +2076,10 @@ func (s *Site) renderHomePage(prepare bool) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viper.GetBool("DisableRSS") {
|
if !viper.GetBool("disableRSS") {
|
||||||
// XML Feed
|
// XML Feed
|
||||||
rssNode := s.newNode("rss-home")
|
rssNode := s.newNode("rss-home")
|
||||||
s.setURLs(rssNode, viper.GetString("RSSUri"))
|
s.setURLs(rssNode, viper.GetString("rssURI"))
|
||||||
rssNode.Title = ""
|
rssNode.Title = ""
|
||||||
high := 50
|
high := 50
|
||||||
if len(s.Pages) < high {
|
if len(s.Pages) < high {
|
||||||
|
@ -2093,12 +2093,12 @@ func (s *Site) renderHomePage(prepare bool) error {
|
||||||
|
|
||||||
rssLayouts := []string{"rss.xml", "_default/rss.xml", "_internal/_default/rss.xml"}
|
rssLayouts := []string{"rss.xml", "_default/rss.xml", "_internal/_default/rss.xml"}
|
||||||
|
|
||||||
if err := s.renderAndWriteXML("homepage rss", rssNode.addLangPathPrefix(viper.GetString("RSSUri")), rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
if err := s.renderAndWriteXML("homepage rss", rssNode.addLangPathPrefix(viper.GetString("rssURI")), rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("Disable404") {
|
if viper.GetBool("disable404") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2138,11 +2138,11 @@ func (s *Site) newPage() *Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) renderSitemap() error {
|
func (s *Site) renderSitemap() error {
|
||||||
if viper.GetBool("DisableSitemap") {
|
if viper.GetBool("disableSitemap") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap"))
|
sitemapDefault := parseSitemap(viper.GetStringMap("sitemap"))
|
||||||
|
|
||||||
n := s.newNode("sitemap")
|
n := s.newNode("sitemap")
|
||||||
|
|
||||||
|
@ -2183,7 +2183,7 @@ func (s *Site) renderSitemap() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) renderRobotsTXT() error {
|
func (s *Site) renderRobotsTXT() error {
|
||||||
if !viper.GetBool("EnableRobotsTXT") {
|
if !viper.GetBool("enableRobotsTXT") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2232,7 +2232,7 @@ func (s *SiteInfo) permalink(plink string) string {
|
||||||
|
|
||||||
func (s *SiteInfo) permalinkStr(plink string) string {
|
func (s *SiteInfo) permalinkStr(plink string) string {
|
||||||
return helpers.MakePermalink(
|
return helpers.MakePermalink(
|
||||||
viper.GetString("BaseURL"),
|
viper.GetString("baseURL"),
|
||||||
s.pathSpec.URLizeAndPrep(plink)).String()
|
s.pathSpec.URLizeAndPrep(plink)).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2323,10 +2323,10 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
|
||||||
defer bp.PutBuffer(outBuffer)
|
defer bp.PutBuffer(outBuffer)
|
||||||
|
|
||||||
var path []byte
|
var path []byte
|
||||||
if viper.GetBool("RelativeURLs") {
|
if viper.GetBool("relativeURLs") {
|
||||||
path = []byte(helpers.GetDottedRelativePath(dest))
|
path = []byte(helpers.GetDottedRelativePath(dest))
|
||||||
} else {
|
} else {
|
||||||
s := viper.GetString("BaseURL")
|
s := viper.GetString("baseURL")
|
||||||
if !strings.HasSuffix(s, "/") {
|
if !strings.HasSuffix(s, "/") {
|
||||||
s += "/"
|
s += "/"
|
||||||
}
|
}
|
||||||
|
@ -2364,31 +2364,31 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
|
||||||
|
|
||||||
transformLinks := transform.NewEmptyTransforms()
|
transformLinks := transform.NewEmptyTransforms()
|
||||||
|
|
||||||
if viper.GetBool("RelativeURLs") || viper.GetBool("CanonifyURLs") {
|
if viper.GetBool("relativeURLs") || viper.GetBool("canonifyURLs") {
|
||||||
transformLinks = append(transformLinks, transform.AbsURL)
|
transformLinks = append(transformLinks, transform.AbsURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.running() && viper.GetBool("watch") && !viper.GetBool("DisableLiveReload") {
|
if s.running() && viper.GetBool("watch") && !viper.GetBool("disableLiveReload") {
|
||||||
transformLinks = append(transformLinks, transform.LiveReloadInject)
|
transformLinks = append(transformLinks, transform.LiveReloadInject)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For performance reasons we only inject the Hugo generator tag on the home page.
|
// For performance reasons we only inject the Hugo generator tag on the home page.
|
||||||
if n, ok := d.(*Node); ok && n.IsHome {
|
if n, ok := d.(*Node); ok && n.IsHome {
|
||||||
if !viper.GetBool("DisableHugoGeneratorInject") {
|
if !viper.GetBool("disableHugoGeneratorInject") {
|
||||||
transformLinks = append(transformLinks, transform.HugoGeneratorInject)
|
transformLinks = append(transformLinks, transform.HugoGeneratorInject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var path []byte
|
var path []byte
|
||||||
|
|
||||||
if viper.GetBool("RelativeURLs") {
|
if viper.GetBool("relativeURLs") {
|
||||||
translated, err := pageTarget.(target.OptionalTranslator).TranslateRelative(dest)
|
translated, err := pageTarget.(target.OptionalTranslator).TranslateRelative(dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
path = []byte(helpers.GetDottedRelativePath(translated))
|
path = []byte(helpers.GetDottedRelativePath(translated))
|
||||||
} else if viper.GetBool("CanonifyURLs") {
|
} else if viper.GetBool("canonifyURLs") {
|
||||||
s := viper.GetString("BaseURL")
|
s := viper.GetString("baseURL")
|
||||||
if !strings.HasSuffix(s, "/") {
|
if !strings.HasSuffix(s, "/") {
|
||||||
s += "/"
|
s += "/"
|
||||||
}
|
}
|
||||||
|
@ -2403,7 +2403,7 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
|
||||||
jww.WARN.Printf("%q is rendered empty\n", dest)
|
jww.WARN.Printf("%q is rendered empty\n", dest)
|
||||||
if dest == "/" {
|
if dest == "/" {
|
||||||
debugAddend := ""
|
debugAddend := ""
|
||||||
if !viper.GetBool("Verbose") {
|
if !viper.GetBool("verbose") {
|
||||||
debugAddend = "* For more debugging information, run \"hugo -v\""
|
debugAddend = "* For more debugging information, run \"hugo -v\""
|
||||||
}
|
}
|
||||||
distinctFeedbackLogger.Printf(`=============================================================
|
distinctFeedbackLogger.Printf(`=============================================================
|
||||||
|
@ -2413,7 +2413,7 @@ Your rendered home page is blank: /index.html is zero-length
|
||||||
%s
|
%s
|
||||||
=============================================================`,
|
=============================================================`,
|
||||||
filepath.Base(viper.ConfigFileUsed()),
|
filepath.Base(viper.ConfigFileUsed()),
|
||||||
viper.GetString("Theme"),
|
viper.GetString("theme"),
|
||||||
debugAddend)
|
debugAddend)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2499,7 +2499,7 @@ func (s *Site) initTargetList() {
|
||||||
if s.targets.page == nil {
|
if s.targets.page == nil {
|
||||||
s.targets.page = &target.PagePub{
|
s.targets.page = &target.PagePub{
|
||||||
PublishDir: s.absPublishDir(),
|
PublishDir: s.absPublishDir(),
|
||||||
UglyURLs: viper.GetBool("UglyURLs"),
|
UglyURLs: viper.GetBool("uglyURLs"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.targets.pageUgly == nil {
|
if s.targets.pageUgly == nil {
|
||||||
|
@ -2544,9 +2544,9 @@ func (s *Site) writeDestAlias(path, permalink string, p *Page) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Site) publishDestAlias(aliasPublisher target.AliasPublisher, path, permalink string, p *Page) (err error) {
|
func (s *Site) publishDestAlias(aliasPublisher target.AliasPublisher, path, permalink string, p *Page) (err error) {
|
||||||
if viper.GetBool("RelativeURLs") {
|
if viper.GetBool("relativeURLs") {
|
||||||
// convert `permalink` into URI relative to location of `path`
|
// convert `permalink` into URI relative to location of `path`
|
||||||
baseURL := helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))
|
baseURL := helpers.SanitizeURLKeepTrailingSlash(viper.GetString("baseURL"))
|
||||||
if strings.HasPrefix(permalink, baseURL) {
|
if strings.HasPrefix(permalink, baseURL) {
|
||||||
permalink = "/" + strings.TrimPrefix(permalink, baseURL)
|
permalink = "/" + strings.TrimPrefix(permalink, baseURL)
|
||||||
}
|
}
|
||||||
|
@ -2572,7 +2572,7 @@ func (s *Site) draftStats() string {
|
||||||
msg = fmt.Sprintf("%d drafts rendered", s.draftCount)
|
msg = fmt.Sprintf("%d drafts rendered", s.draftCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("BuildDrafts") {
|
if viper.GetBool("buildDrafts") {
|
||||||
return fmt.Sprintf("%d of ", s.draftCount) + msg
|
return fmt.Sprintf("%d of ", s.draftCount) + msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2591,7 +2591,7 @@ func (s *Site) futureStats() string {
|
||||||
msg = fmt.Sprintf("%d futures rendered", s.futureCount)
|
msg = fmt.Sprintf("%d futures rendered", s.futureCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("BuildFuture") {
|
if viper.GetBool("buildFuture") {
|
||||||
return fmt.Sprintf("%d of ", s.futureCount) + msg
|
return fmt.Sprintf("%d of ", s.futureCount) + msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2610,7 +2610,7 @@ func (s *Site) expiredStats() string {
|
||||||
msg = fmt.Sprintf("%d expired rendered", s.expiredCount)
|
msg = fmt.Sprintf("%d expired rendered", s.expiredCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
if viper.GetBool("BuildExpired") {
|
if viper.GetBool("buildExpired") {
|
||||||
return fmt.Sprintf("%d of ", s.expiredCount) + msg
|
return fmt.Sprintf("%d of ", s.expiredCount) + msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ func _TestDegenerateNoTarget(t *testing.T) {
|
||||||
func _TestFileTarget(t *testing.T) {
|
func _TestFileTarget(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: fakeSource},
|
Source: &source.InMemorySource{ByteSource: fakeSource},
|
||||||
|
@ -104,8 +104,8 @@ func _TestFileTarget(t *testing.T) {
|
||||||
func _TestPageTargetUgly(t *testing.T) {
|
func _TestPageTargetUgly(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("UglyURLs", true)
|
viper.Set("uglyURLs", true)
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
targets: targetList{page: &target.PagePub{UglyURLs: true, PublishDir: "public"}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true, PublishDir: "public"}},
|
||||||
|
@ -129,7 +129,7 @@ func _TestPageTargetUgly(t *testing.T) {
|
||||||
func _TestFileTargetPublishDir(t *testing.T) {
|
func _TestFileTargetPublishDir(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ func init() {
|
||||||
func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
|
func TestReadPagesFromSourceWithEmptySource(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
|
|
||||||
sources := []source.ByteSource{}
|
sources := []source.ByteSource{}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ func TestDraftAndFutureRender(t *testing.T) {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
|
|
||||||
// Testing Defaults.. Only draft:true and publishDate in the past should be rendered
|
// Testing Defaults.. Only draft:true and publishDate in the past should be rendered
|
||||||
s := siteSetup(t)
|
s := siteSetup(t)
|
||||||
|
@ -152,31 +152,31 @@ func TestDraftAndFutureRender(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// only publishDate in the past should be rendered
|
// only publishDate in the past should be rendered
|
||||||
viper.Set("BuildDrafts", true)
|
viper.Set("buildDrafts", true)
|
||||||
s = siteSetup(t)
|
s = siteSetup(t)
|
||||||
if len(s.AllPages) != 2 {
|
if len(s.AllPages) != 2 {
|
||||||
t.Fatal("Future Dated Posts published unexpectedly")
|
t.Fatal("Future Dated Posts published unexpectedly")
|
||||||
}
|
}
|
||||||
|
|
||||||
// drafts should not be rendered, but all dates should
|
// drafts should not be rendered, but all dates should
|
||||||
viper.Set("BuildDrafts", false)
|
viper.Set("buildDrafts", false)
|
||||||
viper.Set("BuildFuture", true)
|
viper.Set("buildFuture", true)
|
||||||
s = siteSetup(t)
|
s = siteSetup(t)
|
||||||
if len(s.AllPages) != 2 {
|
if len(s.AllPages) != 2 {
|
||||||
t.Fatal("Draft posts published unexpectedly")
|
t.Fatal("Draft posts published unexpectedly")
|
||||||
}
|
}
|
||||||
|
|
||||||
// all 4 should be included
|
// all 4 should be included
|
||||||
viper.Set("BuildDrafts", true)
|
viper.Set("buildDrafts", true)
|
||||||
viper.Set("BuildFuture", true)
|
viper.Set("buildFuture", true)
|
||||||
s = siteSetup(t)
|
s = siteSetup(t)
|
||||||
if len(s.AllPages) != 4 {
|
if len(s.AllPages) != 4 {
|
||||||
t.Fatal("Drafts or Future posts not included as expected")
|
t.Fatal("Drafts or Future posts not included as expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
//setting defaults back
|
//setting defaults back
|
||||||
viper.Set("BuildDrafts", false)
|
viper.Set("buildDrafts", false)
|
||||||
viper.Set("BuildFuture", false)
|
viper.Set("buildFuture", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFutureExpirationRender(t *testing.T) {
|
func TestFutureExpirationRender(t *testing.T) {
|
||||||
|
@ -201,7 +201,7 @@ func TestFutureExpirationRender(t *testing.T) {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
|
|
||||||
s := siteSetup(t)
|
s := siteSetup(t)
|
||||||
|
|
||||||
|
@ -233,9 +233,9 @@ func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
baseURL := "http://foo/bar"
|
baseURL := "http://foo/bar"
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("baseurl", baseURL)
|
viper.Set("baseURL", baseURL)
|
||||||
viper.Set("UglyURLs", uglyURLs)
|
viper.Set("uglyURLs", uglyURLs)
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
|
|
||||||
var refShortcode string
|
var refShortcode string
|
||||||
|
@ -267,7 +267,7 @@ func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
|
||||||
// Issue #1148: Make sure that no P-tags is added around shortcodes.
|
// Issue #1148: Make sure that no P-tags is added around shortcodes.
|
||||||
{
|
{
|
||||||
Name: filepath.FromSlash("sect/doc2.md"),
|
Name: filepath.FromSlash("sect/doc2.md"),
|
||||||
Content: []byte(fmt.Sprintf(`**Ref 1:**
|
Content: []byte(fmt.Sprintf(`**Ref 1:**
|
||||||
|
|
||||||
{{< %s "sect/doc1.md" >}}
|
{{< %s "sect/doc1.md" >}}
|
||||||
|
|
||||||
|
@ -330,18 +330,18 @@ func TestShouldAlwaysHaveUglyURLs(t *testing.T) {
|
||||||
func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
viper.Set("DisableSitemap", false)
|
viper.Set("disableSitemap", false)
|
||||||
viper.Set("DisableRSS", false)
|
viper.Set("disableRSS", false)
|
||||||
viper.Set("RSSUri", "index.xml")
|
viper.Set("rssURI", "index.xml")
|
||||||
viper.Set("blackfriday",
|
viper.Set("blackfriday",
|
||||||
// TODO(bep) https://github.com/spf13/viper/issues/261
|
// TODO(bep) https://github.com/spf13/viper/issues/261
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
strings.ToLower("plainIDAnchors"): true})
|
strings.ToLower("plainIDAnchors"): true})
|
||||||
|
|
||||||
viper.Set("UglyURLs", uglyURLs)
|
viper.Set("uglyURLs", uglyURLs)
|
||||||
|
|
||||||
sources := []source.ByteSource{
|
sources := []source.ByteSource{
|
||||||
{Name: filepath.FromSlash("sect/doc1.md"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
{Name: filepath.FromSlash("sect/doc1.md"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
|
||||||
|
@ -413,11 +413,11 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/sub/")
|
viper.Set("baseURL", "http://auth/sub/")
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("UglyURLs", uglify)
|
viper.Set("uglyURLs", uglify)
|
||||||
viper.Set("PluralizeListTitles", pluralize)
|
viper.Set("pluralizeListTitles", pluralize)
|
||||||
viper.Set("CanonifyURLs", canonify)
|
viper.Set("canonifyURLs", canonify)
|
||||||
|
|
||||||
var expectedPathSuffix string
|
var expectedPathSuffix string
|
||||||
|
|
||||||
|
@ -491,10 +491,10 @@ func TestSkipRender(t *testing.T) {
|
||||||
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("verbose", true)
|
viper.Set("verbose", true)
|
||||||
viper.Set("CanonifyURLs", true)
|
viper.Set("canonifyURLs", true)
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
|
@ -539,7 +539,7 @@ func TestSkipRender(t *testing.T) {
|
||||||
func TestAbsURLify(t *testing.T) {
|
func TestAbsURLify(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
|
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
sources := []source.ByteSource{
|
sources := []source.ByteSource{
|
||||||
|
@ -548,14 +548,14 @@ func TestAbsURLify(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, baseURL := range []string{"http://auth/bub", "http://base", "//base"} {
|
for _, baseURL := range []string{"http://auth/bub", "http://base", "//base"} {
|
||||||
for _, canonify := range []bool{true, false} {
|
for _, canonify := range []bool{true, false} {
|
||||||
viper.Set("CanonifyURLs", canonify)
|
viper.Set("canonifyURLs", canonify)
|
||||||
viper.Set("BaseURL", baseURL)
|
viper.Set("baseURL", baseURL)
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
targets: targetList{page: &target.PagePub{UglyURLs: true}},
|
||||||
Language: helpers.NewDefaultLanguage(),
|
Language: helpers.NewDefaultLanguage(),
|
||||||
}
|
}
|
||||||
t.Logf("Rendering with BaseURL %q and CanonifyURLs set %v", viper.GetString("baseURL"), canonify)
|
t.Logf("Rendering with baseURL %q and canonifyURLs set %v", viper.GetString("baseURL"), canonify)
|
||||||
|
|
||||||
if err := buildAndRenderSite(s, "blue/single.html", templateWithURLAbs); err != nil {
|
if err := buildAndRenderSite(s, "blue/single.html", templateWithURLAbs); err != nil {
|
||||||
t.Fatalf("Failed to build site: %s", err)
|
t.Fatalf("Failed to build site: %s", err)
|
||||||
|
@ -644,7 +644,7 @@ func TestOrderedPages(t *testing.T) {
|
||||||
|
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: weightedSources},
|
Source: &source.InMemorySource{ByteSource: weightedSources},
|
||||||
Language: helpers.NewDefaultLanguage(),
|
Language: helpers.NewDefaultLanguage(),
|
||||||
|
@ -713,7 +713,7 @@ func TestGroupedPages(t *testing.T) {
|
||||||
|
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: groupedSources},
|
Source: &source.InMemorySource{ByteSource: groupedSources},
|
||||||
Language: helpers.NewDefaultLanguage(),
|
Language: helpers.NewDefaultLanguage(),
|
||||||
|
@ -897,7 +897,7 @@ func TestWeightedTaxonomies(t *testing.T) {
|
||||||
taxonomies["tag"] = "tags"
|
taxonomies["tag"] = "tags"
|
||||||
taxonomies["category"] = "categories"
|
taxonomies["category"] = "categories"
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub")
|
viper.Set("baseURL", "http://auth/bub")
|
||||||
viper.Set("taxonomies", taxonomies)
|
viper.Set("taxonomies", taxonomies)
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: sources},
|
Source: &source.InMemorySource{ByteSource: sources},
|
||||||
|
@ -959,11 +959,11 @@ func setupLinkingMockSite(t *testing.T) *Site {
|
||||||
{Name: filepath.FromSlash("level2/level3/common.png"), Content: []byte("")},
|
{Name: filepath.FromSlash("level2/level3/common.png"), Content: []byte("")},
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/")
|
viper.Set("baseURL", "http://auth/")
|
||||||
viper.Set("DefaultExtension", "html")
|
viper.Set("defaultExtension", "html")
|
||||||
viper.Set("UglyURLs", false)
|
viper.Set("uglyURLs", false)
|
||||||
viper.Set("PluralizeListTitles", false)
|
viper.Set("pluralizeListTitles", false)
|
||||||
viper.Set("CanonifyURLs", false)
|
viper.Set("canonifyURLs", false)
|
||||||
viper.Set("blackfriday",
|
viper.Set("blackfriday",
|
||||||
// TODO(bep) see https://github.com/spf13/viper/issues/261
|
// TODO(bep) see https://github.com/spf13/viper/issues/261
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|
|
@ -61,7 +61,7 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) {
|
||||||
{"http://base.com/sub", "http://base.com/sub"},
|
{"http://base.com/sub", "http://base.com/sub"},
|
||||||
{"http://base.com", "http://base.com"}} {
|
{"http://base.com", "http://base.com"}} {
|
||||||
|
|
||||||
viper.Set("BaseURL", this.in)
|
viper.Set("baseURL", this.in)
|
||||||
s := newSiteDefaultLang()
|
s := newSiteDefaultLang()
|
||||||
s.initializeSiteInfo()
|
s.initializeSiteInfo()
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ func TestPageCount(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
hugofs.InitMemFs()
|
hugofs.InitMemFs()
|
||||||
|
|
||||||
viper.Set("uglyurls", false)
|
viper.Set("uglyURLs", false)
|
||||||
viper.Set("paginate", 10)
|
viper.Set("paginate", 10)
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: urlFakeSource},
|
Source: &source.InMemorySource{ByteSource: urlFakeSource},
|
||||||
|
|
|
@ -38,7 +38,7 @@ const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap
|
||||||
func TestSitemapOutput(t *testing.T) {
|
func TestSitemapOutput(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
viper.Set("baseurl", "http://auth/bub/")
|
viper.Set("baseURL", "http://auth/bub/")
|
||||||
|
|
||||||
s := &Site{
|
s := &Site{
|
||||||
Source: &source.InMemorySource{ByteSource: weightedSources},
|
Source: &source.InMemorySource{ByteSource: weightedSources},
|
||||||
|
|
|
@ -128,7 +128,7 @@ func NewFile(relpath string) *File {
|
||||||
|
|
||||||
f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".")
|
f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".")
|
||||||
if f.lang == "" {
|
if f.lang == "" {
|
||||||
f.lang = viper.GetString("DefaultContentLanguage")
|
f.lang = viper.GetString("defaultContentLanguage")
|
||||||
}
|
}
|
||||||
f.translationBaseName = helpers.Filename(f.baseName)
|
f.translationBaseName = helpers.Filename(f.baseName)
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ func isNonProcessablePath(filePath string) bool {
|
||||||
strings.HasSuffix(base, "~") {
|
strings.HasSuffix(base, "~") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
ignoreFiles := viper.GetStringSlice("IgnoreFiles")
|
ignoreFiles := viper.GetStringSlice("ignoreFiles")
|
||||||
if len(ignoreFiles) > 0 {
|
if len(ignoreFiles) > 0 {
|
||||||
for _, ignorePattern := range ignoreFiles {
|
for _, ignorePattern := range ignoreFiles {
|
||||||
match, err := regexp.MatchString(ignorePattern, filePath)
|
match, err := regexp.MatchString(ignorePattern, filePath)
|
||||||
|
|
|
@ -1278,7 +1278,7 @@ func markdownify(in interface{}) (template.HTML, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
language := viper.Get("CurrentContentLanguage").(*helpers.Language)
|
language := viper.Get("currentContentLanguage").(*helpers.Language)
|
||||||
|
|
||||||
m := helpers.RenderBytes(&helpers.RenderingContext{
|
m := helpers.RenderBytes(&helpers.RenderingContext{
|
||||||
ConfigProvider: language,
|
ConfigProvider: language,
|
||||||
|
|
|
@ -75,9 +75,9 @@ func TestFuncsInTemplate(t *testing.T) {
|
||||||
|
|
||||||
workingDir := "/home/hugo"
|
workingDir := "/home/hugo"
|
||||||
|
|
||||||
viper.Set("WorkingDir", workingDir)
|
viper.Set("workingDir", workingDir)
|
||||||
viper.Set("CurrentContentLanguage", helpers.NewDefaultLanguage())
|
viper.Set("currentContentLanguage", helpers.NewDefaultLanguage())
|
||||||
viper.Set("Multilingual", true)
|
viper.Set("multilingual", true)
|
||||||
|
|
||||||
fs := &afero.MemMapFs{}
|
fs := &afero.MemMapFs{}
|
||||||
hugofs.InitFs(fs)
|
hugofs.InitFs(fs)
|
||||||
|
@ -1773,7 +1773,7 @@ func TestReturnWhenSet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMarkdownify(t *testing.T) {
|
func TestMarkdownify(t *testing.T) {
|
||||||
viper.Set("CurrentContentLanguage", helpers.NewDefaultLanguage())
|
viper.Set("currentContentLanguage", helpers.NewDefaultLanguage())
|
||||||
|
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
in interface{}
|
in interface{}
|
||||||
|
@ -2444,7 +2444,7 @@ func TestReadFile(t *testing.T) {
|
||||||
|
|
||||||
workingDir := "/home/hugo"
|
workingDir := "/home/hugo"
|
||||||
|
|
||||||
viper.Set("WorkingDir", workingDir)
|
viper.Set("workingDir", workingDir)
|
||||||
|
|
||||||
fs := &afero.MemMapFs{}
|
fs := &afero.MemMapFs{}
|
||||||
hugofs.InitFs(fs)
|
hugofs.InitFs(fs)
|
||||||
|
|
|
@ -44,14 +44,14 @@ func SetTranslateLang(language *helpers.Language) error {
|
||||||
translator.current = f
|
translator.current = f
|
||||||
} else {
|
} else {
|
||||||
jww.WARN.Printf("Translation func for language %v not found, use default.", language.Lang)
|
jww.WARN.Printf("Translation func for language %v not found, use default.", language.Lang)
|
||||||
translator.current = translator.translateFuncs[viper.GetString("DefaultContentLanguage")]
|
translator.current = translator.translateFuncs[viper.GetString("defaultContentLanguage")]
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||||
translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)}
|
translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)}
|
||||||
defaultContentLanguage := viper.GetString("DefaultContentLanguage")
|
defaultContentLanguage := viper.GetString("defaultContentLanguage")
|
||||||
var (
|
var (
|
||||||
defaultT bundle.TranslateFunc
|
defaultT bundle.TranslateFunc
|
||||||
err error
|
err error
|
||||||
|
@ -76,7 +76,7 @@ func SetI18nTfuncs(bndl *bundle.Bundle) {
|
||||||
if Logi18nWarnings {
|
if Logi18nWarnings {
|
||||||
i18nWarningLogger.Printf("i18n|MISSING_TRANSLATION|%s|%s", currentLang, translationID)
|
i18nWarningLogger.Printf("i18n|MISSING_TRANSLATION|%s|%s", currentLang, translationID)
|
||||||
}
|
}
|
||||||
if viper.GetBool("EnableMissingTranslationPlaceholders") {
|
if viper.GetBool("enableMissingTranslationPlaceholders") {
|
||||||
return fmt.Sprintf("[i18n] %s", translationID)
|
return fmt.Sprintf("[i18n] %s", translationID)
|
||||||
}
|
}
|
||||||
if defaultT != nil {
|
if defaultT != nil {
|
||||||
|
|
|
@ -129,12 +129,12 @@ func doTestI18nTranslate(t *testing.T, data map[string][]byte, lang, id string,
|
||||||
func TestI18nTranslate(t *testing.T) {
|
func TestI18nTranslate(t *testing.T) {
|
||||||
var actual, expected string
|
var actual, expected string
|
||||||
|
|
||||||
viper.SetDefault("DefaultContentLanguage", "en")
|
viper.SetDefault("defaultContentLanguage", "en")
|
||||||
viper.Set("CurrentContentLanguage", helpers.NewLanguage("en"))
|
viper.Set("currentContentLanguage", helpers.NewLanguage("en"))
|
||||||
|
|
||||||
// Test without and with placeholders
|
// Test without and with placeholders
|
||||||
for _, enablePlaceholders := range []bool{false, true} {
|
for _, enablePlaceholders := range []bool{false, true} {
|
||||||
viper.Set("EnableMissingTranslationPlaceholders", enablePlaceholders)
|
viper.Set("enableMissingTranslationPlaceholders", enablePlaceholders)
|
||||||
|
|
||||||
for _, test := range i18nTests {
|
for _, test := range i18nTests {
|
||||||
if enablePlaceholders {
|
if enablePlaceholders {
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (l *remoteLock) URLUnlock(url string) {
|
||||||
|
|
||||||
// getCacheFileID returns the cache ID for a string
|
// getCacheFileID returns the cache ID for a string
|
||||||
func getCacheFileID(id string) string {
|
func getCacheFileID(id string) string {
|
||||||
return viper.GetString("CacheDir") + url.QueryEscape(id)
|
return viper.GetString("cacheDir") + url.QueryEscape(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// resGetCache returns the content for an ID from the file cache or an error
|
// resGetCache returns the content for an ID from the file cache or an error
|
||||||
|
@ -115,7 +115,7 @@ func resDeleteCache(id string, fs afero.Fs) error {
|
||||||
// resGetRemote loads the content of a remote file. This method is thread safe.
|
// resGetRemote loads the content of a remote file. This method is thread safe.
|
||||||
func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
||||||
|
|
||||||
c, err := resGetCache(url, fs, viper.GetBool("IgnoreCache"))
|
c, err := resGetCache(url, fs, viper.GetBool("ignoreCache"))
|
||||||
if c != nil && err == nil {
|
if c != nil && err == nil {
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
||||||
defer func() { remoteURLLock.URLUnlock(url) }()
|
defer func() { remoteURLLock.URLUnlock(url) }()
|
||||||
|
|
||||||
// avoid multiple locks due to calling resGetCache twice
|
// avoid multiple locks due to calling resGetCache twice
|
||||||
c, err = resGetCache(url, fs, viper.GetBool("IgnoreCache"))
|
c, err = resGetCache(url, fs, viper.GetBool("ignoreCache"))
|
||||||
if c != nil && err == nil {
|
if c != nil && err == nil {
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = resWriteCache(url, c, fs, viper.GetBool("IgnoreCache"))
|
err = resWriteCache(url, c, fs, viper.GetBool("ignoreCache"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) {
|
||||||
|
|
||||||
// resGetLocal loads the content of a local file
|
// resGetLocal loads the content of a local file
|
||||||
func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
|
func resGetLocal(url string, fs afero.Fs) ([]byte, error) {
|
||||||
filename := filepath.Join(viper.GetString("WorkingDir"), url)
|
filename := filepath.Join(viper.GetString("workingDir"), url)
|
||||||
if e, err := helpers.Exists(filename, fs); !e {
|
if e, err := helpers.Exists(filename, fs); !e {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,12 +213,12 @@ type wd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRetryWhenDone() wd {
|
func testRetryWhenDone() wd {
|
||||||
cd := viper.GetString("CacheDir")
|
cd := viper.GetString("cacheDir")
|
||||||
viper.Set("CacheDir", helpers.GetTempDir("", hugofs.Source()))
|
viper.Set("cacheDir", helpers.GetTempDir("", hugofs.Source()))
|
||||||
var tmpSleep time.Duration
|
var tmpSleep time.Duration
|
||||||
tmpSleep, resSleep = resSleep, time.Millisecond
|
tmpSleep, resSleep = resSleep, time.Millisecond
|
||||||
return wd{func() {
|
return wd{func() {
|
||||||
viper.Set("CacheDir", cd)
|
viper.Set("cacheDir", cd)
|
||||||
resSleep = tmpSleep
|
resSleep = tmpSleep
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue