diff options
author | Albert Nigmatzianov <[email protected]> | 2016-10-24 20:56:00 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2016-10-24 20:56:00 +0200 |
commit | f21e2f25c99c547a2f35d209935f8f1c52fa2671 (patch) | |
tree | f2bb860213e88b0244c31144cfcd872665096f06 | |
parent | d9f54a13c14f12ccc8af33e9dbd611c2cd113324 (diff) | |
download | hugo-f21e2f25c99c547a2f35d209935f8f1c52fa2671.tar.gz hugo-f21e2f25c99c547a2f35d209935f8f1c52fa2671.zip |
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.
67 files changed, 469 insertions, 469 deletions
diff --git a/commands/convert.go b/commands/convert.go index a0decf25d..a0424c4a9 100644 --- a/commands/convert.go +++ b/commands/convert.go @@ -134,7 +134,7 @@ func convertContents(mark rune) (err error) { 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()) 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) diff --git a/commands/hugo.go b/commands/hugo.go index 3192baf44..376438fcb 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -117,7 +117,7 @@ Complete documentation is available at http://gohugo.io/.`, } if buildWatch { - viper.Set("DisableLiveReload", true) + viper.Set("disableLiveReload", true) watchConfig() } @@ -284,55 +284,55 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error { for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) { if flagChanged(cmdV.PersistentFlags(), "verbose") { - viper.Set("Verbose", verbose) + viper.Set("verbose", verbose) } if flagChanged(cmdV.PersistentFlags(), "logFile") { - viper.Set("LogFile", logFile) + viper.Set("logFile", logFile) } if flagChanged(cmdV.Flags(), "cleanDestinationDir") { viper.Set("cleanDestinationDir", cleanDestination) } if flagChanged(cmdV.Flags(), "buildDrafts") { - viper.Set("BuildDrafts", draft) + viper.Set("buildDrafts", draft) } if flagChanged(cmdV.Flags(), "buildFuture") { - viper.Set("BuildFuture", future) + viper.Set("buildFuture", future) } if flagChanged(cmdV.Flags(), "buildExpired") { - viper.Set("BuildExpired", expired) + viper.Set("buildExpired", expired) } if flagChanged(cmdV.Flags(), "uglyURLs") { - viper.Set("UglyURLs", uglyURLs) + viper.Set("uglyURLs", uglyURLs) } if flagChanged(cmdV.Flags(), "canonifyURLs") { - viper.Set("CanonifyURLs", canonifyURLs) + viper.Set("canonifyURLs", canonifyURLs) } if flagChanged(cmdV.Flags(), "disable404") { - viper.Set("Disable404", disable404) + viper.Set("disable404", disable404) } if flagChanged(cmdV.Flags(), "disableRSS") { - viper.Set("DisableRSS", disableRSS) + viper.Set("disableRSS", disableRSS) } if flagChanged(cmdV.Flags(), "disableSitemap") { - viper.Set("DisableSitemap", disableSitemap) + viper.Set("disableSitemap", disableSitemap) } if flagChanged(cmdV.Flags(), "enableRobotsTXT") { - viper.Set("EnableRobotsTXT", enableRobotsTXT) + viper.Set("enableRobotsTXT", enableRobotsTXT) } if flagChanged(cmdV.Flags(), "pluralizeListTitles") { - viper.Set("PluralizeListTitles", pluralizeListTitles) + viper.Set("pluralizeListTitles", pluralizeListTitles) } if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") { - viper.Set("PreserveTaxonomyNames", preserveTaxonomyNames) + viper.Set("preserveTaxonomyNames", preserveTaxonomyNames) } if flagChanged(cmdV.Flags(), "ignoreCache") { - viper.Set("IgnoreCache", ignoreCache) + viper.Set("ignoreCache", ignoreCache) } if flagChanged(cmdV.Flags(), "forceSyncStatic") { - viper.Set("ForceSyncStatic", forceSync) + viper.Set("forceSyncStatic", forceSync) } 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, "/") { 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.") } @@ -353,27 +353,27 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error { } if destination != "" { - viper.Set("PublishDir", destination) + viper.Set("publishDir", destination) } + var dir string if source != "" { - dir, _ := filepath.Abs(source) - viper.Set("WorkingDir", dir) + dir, _ = filepath.Abs(source) } else { - dir, _ := os.Getwd() - viper.Set("WorkingDir", dir) + dir, _ = os.Getwd() } + viper.Set("workingDir", dir) if contentDir != "" { - viper.Set("ContentDir", contentDir) + viper.Set("contentDir", contentDir) } if layoutDir != "" { - viper.Set("LayoutDir", layoutDir) + viper.Set("layoutDir", layoutDir) } if cacheDir != "" { - viper.Set("CacheDir", cacheDir) + viper.Set("cacheDir", cacheDir) } cacheDir = viper.GetString("cacheDir") @@ -386,14 +386,14 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error { if isDir == false { mkdir(cacheDir) } - viper.Set("CacheDir", cacheDir) + viper.Set("cacheDir", cacheDir) } 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 viper.IsSet("LogFile") && viper.GetString("LogFile") != "" { - jww.SetLogFile(viper.GetString("LogFile")) + if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") { + if viper.IsSet("logFile") && viper.GetString("logFile") != "" { + jww.SetLogFile(viper.GetString("logFile")) } else { jww.UseTempLogFile("hugo") } @@ -448,7 +448,7 @@ func watchConfig() { fmt.Println("Config file changed:", e.Name) // Force a full rebuild 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 livereload.ForceRefresh() } @@ -463,11 +463,11 @@ func build(watches ...bool) error { if renderToMemory { hugofs.SetDestination(new(afero.MemMapFs)) // Rendering to memoryFS, publish to Root regardless of publishDir. - viper.Set("PublishDir", "/") + viper.Set("publishDir", "/") } 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 if len(watches) > 0 && watches[0] { @@ -478,7 +478,7 @@ func build(watches ...bool) error { } 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") utils.CheckErr(NewWatcher(0)) } @@ -532,7 +532,7 @@ func getStaticSourceFs() afero.Fs { } 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 publishDir == "//" { @@ -567,10 +567,10 @@ func copyStatic() error { // getDirList provides NewWatcher() with a list of directories to watch for changes. func getDirList() []string { var a []string - dataDir := helpers.AbsPathify(viper.GetString("DataDir")) - i18nDir := helpers.AbsPathify(viper.GetString("I18nDir")) - layoutDir := helpers.AbsPathify(viper.GetString("LayoutDir")) - staticDir := helpers.AbsPathify(viper.GetString("StaticDir")) + dataDir := helpers.AbsPathify(viper.GetString("dataDir")) + i18nDir := helpers.AbsPathify(viper.GetString("i18nDir")) + layoutDir := helpers.AbsPathify(viper.GetString("layoutDir")) + staticDir := helpers.AbsPathify(viper.GetString("staticDir")) var themesDir string if helpers.ThemeSet() { @@ -580,22 +580,22 @@ func getDirList() []string { walker := func(path string, fi os.FileInfo, err error) error { if err != nil { if path == dataDir && os.IsNotExist(err) { - jww.WARN.Println("Skip DataDir:", err) + jww.WARN.Println("Skip dataDir:", err) return nil } if path == i18nDir && os.IsNotExist(err) { - jww.WARN.Println("Skip I18nDir:", err) + jww.WARN.Println("Skip i18nDir:", err) return nil } if path == layoutDir && os.IsNotExist(err) { - jww.WARN.Println("Skip LayoutDir:", err) + jww.WARN.Println("Skip layoutDir:", err) return nil } if path == staticDir && os.IsNotExist(err) { - jww.WARN.Println("Skip StaticDir:", err) + jww.WARN.Println("Skip staticDir:", err) return nil } @@ -636,9 +636,9 @@ func getDirList() []string { } 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(), helpers.AbsPathify(viper.GetString("LayoutDir")), walker) + helpers.SymbolicWalk(hugofs.Source(), helpers.AbsPathify(viper.GetString("layoutDir")), walker) helpers.SymbolicWalk(hugofs.Source(), staticDir, walker) if helpers.ThemeSet() { @@ -801,7 +801,7 @@ func NewWatcher(port int) error { } 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 publishDir == "//" { @@ -812,11 +812,11 @@ func NewWatcher(port int) error { const layout = "2006-01-02 15:04 -0700" fmt.Println(time.Now().Format(layout)) - if viper.GetBool("ForceSyncStatic") { + if viper.GetBool("forceSyncStatic") { jww.FEEDBACK.Printf("Syncing all static files\n") err := copyStatic() 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 { 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 // force refresh when more than one file @@ -919,7 +919,7 @@ func NewWatcher(port int) error { 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 livereload.ForceRefresh() } @@ -933,7 +933,7 @@ func NewWatcher(port int) error { }() if port > 0 { - if !viper.GetBool("DisableLiveReload") { + if !viper.GetBool("disableLiveReload") { livereload.Initialize() http.HandleFunc("/livereload.js", livereload.ServeJS) http.HandleFunc("/livereload", livereload.Handler) diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go index ca65acb7c..8e74fa8d1 100644 --- a/commands/import_jekyll.go +++ b/commands/import_jekyll.go @@ -221,7 +221,7 @@ func loadJekyllConfig(jekyllRoot string) map[string]interface{} { func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]interface{}) (err error) { title := "My New Hugo Site" - baseurl := "http://example.org/" + baseURL := "http://example.org/" for key, value := range jekyllConfig { lowerKey := strings.ToLower(key) @@ -234,13 +234,13 @@ func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string] case "url": if str, ok := value.(string); ok { - baseurl = str + baseURL = str } } } in := map[string]interface{}{ - "baseurl": baseurl, + "baseURL": baseURL, "title": title, "languageCode": "en-us", "disablePathToLower": true, diff --git a/commands/list.go b/commands/list.go index 423f1868f..fdf72a67e 100644 --- a/commands/list.go +++ b/commands/list.go @@ -49,7 +49,7 @@ var listDraftsCmd = &cobra.Command{ return err } - viper.Set("BuildDrafts", true) + viper.Set("buildDrafts", true) sites, err := hugolib.NewHugoSitesFromConfiguration() @@ -84,7 +84,7 @@ posted in the future.`, return err } - viper.Set("BuildFuture", true) + viper.Set("buildFuture", true) sites, err := hugolib.NewHugoSitesFromConfiguration() @@ -119,7 +119,7 @@ expired.`, return err } - viper.Set("BuildExpired", true) + viper.Set("buildExpired", true) sites, err := hugolib.NewHugoSitesFromConfiguration() diff --git a/commands/new.go b/commands/new.go index a75a6f758..39392d5b9 100644 --- a/commands/new.go +++ b/commands/new.go @@ -89,11 +89,11 @@ func NewContent(cmd *cobra.Command, args []string) error { } if flagChanged(cmd.Flags(), "format") { - viper.Set("MetaDataFormat", configFormat) + viper.Set("metaDataFormat", configFormat) } if flagChanged(cmd.Flags(), "editor") { - viper.Set("NewContentEditor", contentEditor) + viper.Set("newContentEditor", contentEditor) } if len(args) < 1 { diff --git a/commands/server.go b/commands/server.go index ffaaf1fd8..f90278ce8 100644 --- a/commands/server.go +++ b/commands/server.go @@ -90,7 +90,7 @@ func init() { 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().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(&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") @@ -109,11 +109,11 @@ func server(cmd *cobra.Command, args []string) error { } if flagChanged(cmd.Flags(), "disableLiveReload") { - viper.Set("DisableLiveReload", disableLiveReload) + viper.Set("disableLiveReload", disableLiveReload) } if serverWatch { - viper.Set("Watch", true) + viper.Set("watch", true) } if viper.GetBool("watch") { @@ -139,11 +139,11 @@ func server(cmd *cobra.Command, args []string) error { viper.Set("port", serverPort) - BaseURL, err := fixURL(baseURL) + baseURL, err = fixURL(baseURL) if err != nil { return err } - viper.Set("BaseURL", BaseURL) + viper.Set("baseURL", baseURL) if err := memStats(); err != nil { jww.ERROR.Println("memstats error:", err) @@ -158,7 +158,7 @@ func server(cmd *cobra.Command, args []string) error { if !renderToDisk { hugofs.SetDestination(new(afero.MemMapFs)) // Rendering to memoryFS, publish to Root regardless of publishDir. - viper.Set("PublishDir", "/") + viper.Set("publishDir", "/") } 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 if serverWatch { watchDirs := getDirList() - baseWatchDir := viper.GetString("WorkingDir") + baseWatchDir := viper.GetString("workingDir") for i, dir := range watchDirs { watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir) } @@ -190,19 +190,19 @@ func server(cmd *cobra.Command, args []string) error { func serve(port int) { 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 { jww.FEEDBACK.Println("Serving pages from memory") } 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) // We're only interested in the path - u, err := url.Parse(viper.GetString("BaseURL")) + u, err := url.Parse(viper.GetString("baseURL")) if err != nil { - jww.ERROR.Fatalf("Invalid BaseURL: %s", err) + jww.ERROR.Fatalf("Invalid baseURL: %s", err) } if u.Path == "" || u.Path == "/" { 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. func fixURL(s string) (string, error) { useLocalhost := false if s == "" { - s = viper.GetString("BaseURL") + s = viper.GetString("baseURL") useLocalhost = true } @@ -262,7 +262,7 @@ func fixURL(s string) (string, error) { if strings.Contains(u.Host, ":") { u.Host, _, err = net.SplitHostPort(u.Host) 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) diff --git a/commands/server_test.go b/commands/server_test.go index 92afe1928..dea79ed7e 100644 --- a/commands/server_test.go +++ b/commands/server_test.go @@ -46,7 +46,7 @@ func TestFixURL(t *testing.T) { for i, test := range tests { viper.Reset() baseURL = test.CLIBaseURL - viper.Set("BaseURL", test.CfgBaseURL) + viper.Set("baseURL", test.CfgBaseURL) serverAppend = test.AppendPort serverPort = test.Port result, err := fixURL(baseURL) diff --git a/create/content.go b/create/content.go index 0daebc3ad..fb9ef7a04 100644 --- a/create/content.go +++ b/create/content.go @@ -67,7 +67,7 @@ func NewContent(fs afero.Fs, kind, name string) (err error) { 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 } @@ -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") - editor := viper.GetString("NewContentEditor") + editor := viper.GetString("newContentEditor") if 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)) } - 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) } diff --git a/create/content_test.go b/create/content_test.go index 0ccbd03ea..50acc89b4 100644 --- a/create/content_test.go +++ b/create/content_test.go @@ -69,7 +69,7 @@ func TestNewContent(t *testing.T) { func initViper() { viper.Reset() - viper.Set("MetaDataFormat", "toml") + viper.Set("metaDataFormat", "toml") viper.Set("archetypeDir", filepath.Join(os.TempDir(), "archetypes")) viper.Set("contentDir", filepath.Join(os.TempDir(), "content")) viper.Set("themesDir", filepath.Join(os.TempDir(), "themes")) diff --git a/docs/content/content/multilingual.md b/docs/content/content/multilingual.md index 0f3f44295..5d591bc29 100644 --- a/docs/content/content/multilingual.md +++ b/docs/content/content/multilingual.md @@ -14,7 +14,7 @@ Hugo supports multiple languages side-by-side (added in `Hugo 0.17`). Define the Example: ``` -DefaultContentLanguage = "en" +defaultContentLanguage = "en" Languages: 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 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. @@ -81,10 +81,10 @@ You can also have: 1. `/content/about.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. -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. @@ -159,14 +159,12 @@ To track down missing translation strings, run Hugo with the `--i18n-warnings` f i18n|MISSING_TRANSLATION|en|wordCount ``` - - ### 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: ```toml -DefaultContentLanguage = "en" +defaultContentLanguage = "en" [languages.en] weight = 0 diff --git a/docs/content/extras/aliases.md b/docs/content/extras/aliases.md index da861387c..252c348cc 100644 --- a/docs/content/extras/aliases.md +++ b/docs/content/extras/aliases.md @@ -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. -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 <!DOCTYPE html> diff --git a/docs/content/extras/menus.md b/docs/content/extras/menus.md index 3184b6f39..3817a7257 100644 --- a/docs/content/extras/menus.md +++ b/docs/content/extras/menus.md @@ -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 @@ -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. 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 linktitle is present, etc. In practice Name and Identifier are never diff --git a/docs/content/extras/urls.md b/docs/content/extras/urls.md index 95e80a0cf..af540088d 100644 --- a/docs/content/extras/urls.md +++ b/docs/content/extras/urls.md @@ -35,11 +35,11 @@ Organization](/content/organization/) for more details. By default, all relative URLs encountered in the input are left unmodified, 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 -be *canonicalized* using `baseurl`. For example, assuming you have -`baseurl = http://yoursite.example.com/` defined in the site-wide +By setting `canonifyURLs` to `true`, all relative URLs would instead +be *canonicalized* using `baseURL`. For example, assuming you have +`baseURL = http://yoursite.example.com/` defined in the site-wide `config.toml`, the relative URL `/css/foo.css` would be turned into 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 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 diff --git a/docs/content/meta/release-notes.md b/docs/content/meta/release-notes.md index e9ed75ca2..76650620a 100644 --- a/docs/content/meta/release-notes.md +++ b/docs/content/meta/release-notes.md @@ -218,7 +218,7 @@ times decreased anywhere from 10% to 99%. * Use absolute path when editing with editor {{<gh 1589>}} * Fix hugo server "Watching for changes" path display {{<gh 1721>}} * 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>}} * Fix shortcode handling in RST {{<gh 1904>}} * 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` * 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 support for `canonifyurls` in `srcset` +* Add support for `canonifyURLs` in `srcset` * Add shortcode support for HTML (content) files * Allow the same `shortcode` to be used with or without inline content * 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 crossrefs on Windows. * 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. ## Notices diff --git a/docs/content/overview/configuration.md b/docs/content/overview/configuration.md index 4ba00664d..cbf7938ac 100644 --- a/docs/content/overview/configuration.md +++ b/docs/content/overview/configuration.md @@ -49,7 +49,7 @@ Three periods end the document: ```yaml --- -baseurl: "http://yoursite.example.com/" +baseURL: "http://yoursite.example.com/" ... ``` 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: ```toml -contentdir = "content" -layoutdir = "layouts" -publishdir = "public" -builddrafts = false -baseurl = "http://yoursite.example.com/" -canonifyurls = true +contentDir = "content" +layoutDir = "layouts" +publishDir = "public" +buildDrafts = false +baseURL = "http://yoursite.example.com/" +canonifyURLs = true [taxonomies] category = "categories" @@ -76,9 +76,9 @@ Here is a YAML configuration file which sets a few more options: ```yaml --- -baseurl: "http://yoursite.example.com/" +baseURL: "http://yoursite.example.com/" title: "Yoyodyne Widget Blogging" -footnotereturnlinkcontents: "↩" +footnoteReturnLinkContents: "↩" permalinks: post: /:year/:month/:title/ params: @@ -97,7 +97,7 @@ Following is a list of Hugo-defined variables you can configure, along with their current, default values: --- - archetypedir: "archetype" + archetypeDir: "archetype" # hostname (and path) to the root, e.g. http://spf13.com/ baseURL: "" # include content marked as draft @@ -111,14 +111,14 @@ along with their current, default values: canonifyURLs: false # config file (default is path/config.yaml|json|toml) config: "config.toml" - contentdir: "content" + contentDir: "content" dataDir: "data" defaultExtension: "html" defaultLayout: "post" # 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/ - DefaultContentLanguageInSubdir: false + defaultContentLanguageInSubdir: false disableLiveReload: false # Do not build RSS files disableRSS: false @@ -142,7 +142,7 @@ along with their current, default values: # google analytics tracking id googleAnalytics: "" languageCode: "" - layoutdir: "layouts" + layoutDir: "layouts" # Enable Logging log: false # 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") preserveTaxonomyNames: false # filesystem path to write files to - publishdir: "public" + publishDir: "public" # enables syntax guessing for code fences without specified language pygmentsCodeFencesGuessSyntax: false # color-codes for highlighting derived from this style @@ -171,11 +171,11 @@ along with their current, default values: sitemap: # filesystem path to read files relative from source: "" - staticdir: "static" + staticDir: "static" # display memory and timing of different steps of the program stepAnalysis: false # theme to use (located by default in /themes/THEMENAME/) - themesdir: "themes" + themesDir: "themes" theme: "" title: "" # if true, use /filename.html instead of /filename/ diff --git a/docs/content/overview/introduction.md b/docs/content/overview/introduction.md index 9f344c00a..f2ad71cd8 100644 --- a/docs/content/overview/introduction.md +++ b/docs/content/overview/introduction.md @@ -80,7 +80,7 @@ can see what the pages look like. The second component is used when you're ready to publish your web 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 links work properly with most hosting companies. diff --git a/docs/content/overview/quickstart.md b/docs/content/overview/quickstart.md index a44892e89..78bd75ec3 100644 --- a/docs/content/overview/quickstart.md +++ b/docs/content/overview/quickstart.md @@ -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. -* **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. @@ -318,7 +318,7 @@ The website uses the dummy values specified in `bookshelf/config.toml`. Let's update the configuration. ```toml -baseurl = "http://example.org/" +baseURL = "http://example.org/" languageCode = "en-us" 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 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. diff --git a/docs/content/templates/content.md b/docs/content/templates/content.md index c5c551cc8..f0db5f8ce 100644 --- a/docs/content/templates/content.md +++ b/docs/content/templates/content.md @@ -69,7 +69,7 @@ It makes use of [partial templates](/templates/partials/) {{ partial "header.html" . }} {{ partial "subheader.html" . }} - {{ $baseurl := .Site.BaseURL }} + {{ $baseURL := .Site.BaseURL }} <section id="main"> <h1 id="title">{{ .Title }}</h1> @@ -88,12 +88,12 @@ It makes use of [partial templates](/templates/partials/) </section> <ul id="categories"> {{ range .Params.topics }} - <li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li> + <li><a href="{{ $baseURL }}/topics/{{ . | urlize }}">{{ . }}</a> </li> {{ end }} </ul> <ul id="tags"> {{ range .Params.tags }} - <li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li> + <li> <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> </li> {{ end }} </ul> </div> @@ -118,7 +118,7 @@ It makes use of [partial templates](/templates/partials/) {{ partial "header.html" . }} {{ partial "subheader.html" . }} - {{ $baseurl := .Site.BaseURL }} + {{ $baseURL := .Site.BaseURL }} <section id="main"> <h1 id="title">{{ .Title }}</h1> @@ -137,12 +137,12 @@ It makes use of [partial templates](/templates/partials/) </section> <ul id="categories"> {{ range .Params.topics }} - <li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li> + <li><a href="{{ $baseURL }}/topics/{{ . | urlize }}">{{ . }}</a> </li> {{ end }} </ul> <ul id="tags"> {{ range .Params.tags }} - <li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li> + <li> <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> </li> {{ end }} </ul> </div> diff --git a/docs/content/templates/go-templates.md b/docs/content/templates/go-templates.md index 58ad75cc2..114d02d11 100644 --- a/docs/content/templates/go-templates.md +++ b/docs/content/templates/go-templates.md @@ -267,7 +267,7 @@ access this from within the loop, you will likely want to do one of the followin {{ $title := .Site.Title }} {{ range .Params.tags }} <li> - <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> + <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li> {{ end }} @@ -281,7 +281,7 @@ access this from within the loop, you will likely want to do one of the followin {{ range .Params.tags }} <li> - <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> + <a href="{{ $baseURL }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $.Site.Title }} </li> {{ end }} diff --git a/docs/content/templates/variables.md b/docs/content/templates/variables.md index b85387b46..970be23ce 100644 --- a/docs/content/templates/variables.md +++ b/docs/content/templates/variables.md @@ -159,7 +159,7 @@ Also available is `.Site` which has the following: **.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: - baseurl = "http://yoursite.example.com/" + baseURL = "http://yoursite.example.com/" [params] description = "Tesla's Awesome Hugo Site" diff --git a/docs/content/tutorials/create-a-multilingual-site.md b/docs/content/tutorials/create-a-multilingual-site.md index c5d35379d..8a2dd960e 100644 --- a/docs/content/tutorials/create-a-multilingual-site.md +++ b/docs/content/tutorials/create-a-multilingual-site.md @@ -11,7 +11,7 @@ title: Create a Multilingual Site 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 @@ -30,10 +30,10 @@ Create your site configs in the root of your repository, for example for an Engl **English Config `config_en.toml`**: ~~~toml -baseurl = "http://acme.com/" +baseURL = "http://acme.com/" title = "Acme Inc." -contentdir = "content/en" -publishdir = "public/en" +contentDir = "content/en" +publishDir = "public/en" [params] locale = "en-US" @@ -42,10 +42,10 @@ publishdir = "public/en" **Japanese Config `config_ja.toml`**: ~~~toml -baseurl = "http://acme.jp/" +baseURL = "http://acme.jp/" title = "有限会社アクミー" -contentdir = "content/ja" -publishdir = "public/ja" +contentDir = "content/ja" +publishDir = "public/ja" [params] 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`**: ~~~yaml -topslogan: Acme Inc. -topsubslogan: You'll love us +topSlogan: Acme Inc. +topSubslogan: You'll love us ... ~~~ **Japanese Strings `ja-JP.yaml`**: ~~~yaml -topslogan: 有限会社アクミー -topsubslogan: キット勝つぞ +topSlogan: 有限会社アクミー +topSubslogan: キット勝つぞ ... ~~~ @@ -90,8 +90,8 @@ Now you can reference the strings in your templates. One way is to do it like in </head> <body> <div class="container"> - <h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topslogan }}</h1> - <h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topsubslogan }}</h3> + <h1 class="header">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSlogan }}</h1> + <h3 class="subheader">{{ ( index $.Site.Data.translations $.Site.Params.locale ).topSubslogan }}</h3> </div> </body> </html> @@ -126,7 +126,7 @@ At the time of this writing, Golang does not yet have support for internationali </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 diff --git a/docs/content/tutorials/creating-a-new-theme.md b/docs/content/tutorials/creating-a-new-theme.md index 2f5f93fe3..17846d375 100644 --- a/docs/content/tutorials/creating-a-new-theme.md +++ b/docs/content/tutorials/creating-a-new-theme.md @@ -489,7 +489,7 @@ So, let's edit your configuration file to add the theme name: ```toml $ vi config.toml theme = "zafta" -baseurl = "http://example.org/" +baseURL = "http://example.org/" title = "My New Hugo Site" languageCode = "en-us" :wq @@ -1074,13 +1074,13 @@ templates _much_ easier — so, I'll cover them, now. ### Base URL 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 to your web server. Whenever you test your theme, you start Hugo in web server mode (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 work for you. diff --git a/docs/content/tutorials/github-pages-blog.md b/docs/content/tutorials/github-pages-blog.md index 4e11e4783..a5c5d5937 100644 --- a/docs/content/tutorials/github-pages-blog.md +++ b/docs/content/tutorials/github-pages-blog.md @@ -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 -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" - layoutdir: "layouts" - publishdir: "public" + contentDir: "content" + layoutDir: "layouts" + publishDir: "public" indexes: 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" - 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 -> 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* > 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 -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>/ @@ -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. -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. @@ -190,22 +190,22 @@ To build all draft posts *(If you only have drafts, no site will be generated)* **Deploy.sh:** #!/bin/bash - + echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" - + # Build the project. hugo - + # Add changes to git. git add -A - + # Commit changes. msg="rebuilding site `date`" if [ $# -eq 1 ] then msg="$1" fi git commit -m "$msg" - + # Push source and build repos. git push origin master git subtree push --prefix=public [email protected]:spencerlyon2/hugo_gh_blog.git gh-pages diff --git a/docs/content/tutorials/migrate-from-jekyll.md b/docs/content/tutorials/migrate-from-jekyll.md index a797949a7..0fd5d4af7 100644 --- a/docs/content/tutorials/migrate-from-jekyll.md +++ b/docs/content/tutorials/migrate-from-jekyll.md @@ -46,7 +46,7 @@ The default is for Jekyll to publish to `_site` and for Hugo to publish to `publ { .. - "publishdir": "_site", + "publishDir": "_site", .. } diff --git a/examples/blog/config.toml b/examples/blog/config.toml index 0adbfc4da..b402f2c7f 100644 --- a/examples/blog/config.toml +++ b/examples/blog/config.toml @@ -1,4 +1,4 @@ -baseurl = "http://blog.hugoexample.com/" +baseURL = "http://blog.hugoexample.com/" languageCode = "en-us" title = "Hugo Example Blog" -canonifyurls = true +canonifyURLs = true diff --git a/examples/multilingual/config.toml b/examples/multilingual/config.toml index 9f436859a..231e3329f 100644 --- a/examples/multilingual/config.toml +++ b/examples/multilingual/config.toml @@ -1,6 +1,6 @@ -baseurl = "http://example.com" +baseURL = "http://example.com" [taxonomies] tag = "tags" group = "groups" -menu = "menu"
\ No newline at end of file +menu = "menu" diff --git a/helpers/configProvider.go b/helpers/configProvider.go index a631ea63d..e63112c0c 100644 --- a/helpers/configProvider.go +++ b/helpers/configProvider.go @@ -49,7 +49,7 @@ func Config() ConfigProvider { return currentConfigProvider } // 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. diff --git a/helpers/content.go b/helpers/content.go index 5c9533330..eb8987b33 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -182,8 +182,8 @@ func BytesToHTML(b []byte) template.HTML { // getHTMLRenderer creates a new Blackfriday HTML Renderer with the given configuration. func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer { renderParameters := blackfriday.HtmlRendererParameters{ - FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"), - FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"), + FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"), + FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"), } 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. func getMmarkHTMLRenderer(defaultFlags int, ctx *RenderingContext) mmark.Renderer { renderParameters := mmark.HtmlRendererParameters{ - FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"), - FootnoteReturnLinkContents: viper.GetString("FootnoteReturnLinkContents"), + FootnoteAnchorPrefix: viper.GetString("footnoteAnchorPrefix"), + FootnoteReturnLinkContents: viper.GetString("footnoteReturnLinkContents"), } b := len(ctx.DocumentID) != 0 diff --git a/helpers/content_renderer.go b/helpers/content_renderer.go index 6bd2212e1..dbc29f431 100644 --- a/helpers/content_renderer.go +++ b/helpers/content_renderer.go @@ -34,8 +34,8 @@ type HugoHTMLRenderer struct { } func (renderer *HugoHTMLRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) { - if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) { - opts := viper.GetString("PygmentsOptions") + if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) { + opts := viper.GetString("pygmentsOptions") str := html.UnescapeString(string(text)) out.WriteString(Highlight(str, lang, opts)) } 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) { - if viper.GetBool("PygmentsCodeFences") && (lang != "" || viper.GetBool("PygmentsCodeFencesGuessSyntax")) { + if viper.GetBool("pygmentsCodeFences") && (lang != "" || viper.GetBool("pygmentsCodeFencesGuessSyntax")) { str := html.UnescapeString(string(text)) out.WriteString(Highlight(str, lang, "")) } else { diff --git a/helpers/content_renderer_test.go b/helpers/content_renderer_test.go index 7baaadb20..82168fcfd 100644 --- a/helpers/content_renderer_test.go +++ b/helpers/content_renderer_test.go @@ -62,11 +62,11 @@ func TestCodeFence(t *testing.T) { viper.Reset() defer viper.Reset() - viper.Set("PygmentsStyle", "monokai") - viper.Set("PygmentsUseClasses", true) + viper.Set("pygmentsStyle", "monokai") + viper.Set("pygmentsUseClasses", true) for i, d := range data { - viper.Set("PygmentsCodeFences", d.enabled) + viper.Set("pygmentsCodeFences", d.enabled) result := render(d.input) diff --git a/helpers/language.go b/helpers/language.go index 0a1affd18..4bde0aff6 100644 --- a/helpers/language.go +++ b/helpers/language.go @@ -54,7 +54,7 @@ func NewLanguage(lang string) *Language { } func NewDefaultLanguage() *Language { - defaultLang := viper.GetString("DefaultContentLanguage") + defaultLang := viper.GetString("defaultContentLanguage") if defaultLang == "" { defaultLang = "en" @@ -83,7 +83,7 @@ func (l *Language) Params() map[string]interface{} { // Merge with global config. // TODO(bep) consider making this part of a constructor func. - globalParams := viper.GetStringMap("Params") + globalParams := viper.GetStringMap("params") for k, v := range globalParams { if _, ok := l.params[k]; !ok { l.params[k] = v diff --git a/helpers/path.go b/helpers/path.go index cf49858ee..68a72b71a 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -154,13 +154,13 @@ func AbsPathify(inPath string) string { } // 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 // for the current Hugo project. 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. @@ -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. func PaginateAliasPath(base string, page int) string { paginatePath := Config().GetString("paginatePath") - uglify := viper.GetBool("UglyURLs") + uglify := viper.GetBool("uglyURLs") var p string if base != "" { p = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page)) diff --git a/helpers/path_test.go b/helpers/path_test.go index ef0c16505..049499108 100644 --- a/helpers/path_test.go +++ b/helpers/path_test.go @@ -34,7 +34,7 @@ import ( ) func initCommonTestConfig() { - viper.Set("CurrentContentLanguage", NewLanguage("en")) + viper.Set("currentContentLanguage", NewLanguage("en")) } func TestMakePath(t *testing.T) { @@ -61,7 +61,7 @@ func TestMakePath(t *testing.T) { } for _, test := range tests { - viper.Set("RemovePathAccents", test.removeAccents) + viper.Set("removePathAccents", test.removeAccents) p := NewPathSpecFromConfig(viper.GetViper()) output := p.MakePath(test.input) if output != test.expected { @@ -102,7 +102,7 @@ func TestMakePathSanitizedDisablePathToLower(t *testing.T) { defer viper.Reset() initCommonTestConfig() - viper.Set("DisablePathToLower", true) + viper.Set("disablePathToLower", true) p := NewPathSpecFromConfig(viper.GetViper()) tests := []struct { @@ -549,7 +549,7 @@ func TestAbsPathify(t *testing.T) { for i, d := range data { viper.Reset() // todo see comment in AbsPathify - viper.Set("WorkingDir", d.workingDir) + viper.Set("workingDir", d.workingDir) expected := AbsPathify(d.inPath) if d.expected != expected { @@ -559,7 +559,7 @@ func TestAbsPathify(t *testing.T) { t.Logf("Running platform specific path tests for %s", runtime.GOOS) if runtime.GOOS == "windows" { for i, d := range windowsData { - viper.Set("WorkingDir", d.workingDir) + viper.Set("workingDir", d.workingDir) expected := AbsPathify(d.inPath) if d.expected != expected { @@ -568,7 +568,7 @@ func TestAbsPathify(t *testing.T) { } } else { for i, d := range unixData { - viper.Set("WorkingDir", d.workingDir) + viper.Set("workingDir", d.workingDir) expected := AbsPathify(d.inPath) if d.expected != expected { diff --git a/helpers/pygments.go b/helpers/pygments.go index 6f7485845..d729be5dc 100644 --- a/helpers/pygments.go +++ b/helpers/pygments.go @@ -17,15 +17,16 @@ import ( "bytes" "crypto/sha1" "fmt" - "github.com/spf13/hugo/hugofs" - jww "github.com/spf13/jwalterweatherman" - "github.com/spf13/viper" "io" "io/ioutil" "os/exec" "path/filepath" "sort" "strings" + + "github.com/spf13/hugo/hugofs" + jww "github.com/spf13/jwalterweatherman" + "github.com/spf13/viper" ) const pygmentsBin = "pygmentize" @@ -62,8 +63,8 @@ func Highlight(code, lang, optsStr string) string { fs := hugofs.Os() - ignoreCache := viper.GetBool("IgnoreCache") - cacheDir := viper.GetString("CacheDir") + ignoreCache := viper.GetBool("ignoreCache") + cacheDir := viper.GetString("cacheDir") var cachefile string if !ignoreCache && cacheDir != "" { @@ -198,17 +199,17 @@ func createOptionsString(options map[string]string) string { func parseDefaultPygmentsOpts() (map[string]string, error) { options := make(map[string]string) - err := parseOptions(options, viper.GetString("PygmentsOptions")) + err := parseOptions(options, viper.GetString("pygmentsOptions")) if err != nil { return nil, err } - if viper.IsSet("PygmentsStyle") { - options["style"] = viper.GetString("PygmentsStyle") + if viper.IsSet("pygmentsStyle") { + options["style"] = viper.GetString("pygmentsStyle") } - if viper.IsSet("PygmentsUseClasses") { - if viper.GetBool("PygmentsUseClasses") { + if viper.IsSet("pygmentsUseClasses") { + if viper.GetBool("pygmentsUseClasses") { options["noclasses"] = "false" } else { options["noclasses"] = "true" diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go index 7ee07828c..1cca68eac 100644 --- a/helpers/pygments_test.go +++ b/helpers/pygments_test.go @@ -35,8 +35,8 @@ func TestParsePygmentsArgs(t *testing.T) { {"style", "foo", false, false}, } { viper.Reset() - viper.Set("PygmentsStyle", this.pygmentsStyle) - viper.Set("PygmentsUseClasses", this.pygmentsUseClasses) + viper.Set("pygmentsStyle", this.pygmentsStyle) + viper.Set("pygmentsUseClasses", this.pygmentsUseClasses) result1, err := parsePygmentsOpts(this.in) if b, ok := this.expect1.(bool); ok && !b { @@ -72,14 +72,14 @@ func TestParseDefaultPygmentsArgs(t *testing.T) { } { viper.Reset() - viper.Set("PygmentsOptions", this.pygmentsOptions) + viper.Set("pygmentsOptions", this.pygmentsOptions) if s, ok := this.pygmentsStyle.(string); ok { - viper.Set("PygmentsStyle", s) + viper.Set("pygmentsStyle", s) } if b, ok := this.pygmentsUseClasses.(bool); ok { - viper.Set("PygmentsUseClasses", b) + viper.Set("pygmentsUseClasses", b) } result, err := parsePygmentsOpts(this.in) diff --git a/helpers/url.go b/helpers/url.go index ffb0ba234..3c178f0ff 100644 --- a/helpers/url.go +++ b/helpers/url.go @@ -157,7 +157,7 @@ func (p *PathSpec) AbsURL(in string, addLanguage bool) string { return in } - baseURL := viper.GetString("BaseURL") + baseURL := viper.GetString("baseURL") if strings.HasPrefix(in, "/") { p, err := url.Parse(baseURL) if err != nil { @@ -219,7 +219,7 @@ func IsAbsURL(path string) bool { // RelURL creates a URL relative to the BaseURL root. // Note: The result URL will not include the context root if canonifyURLs is enabled. func (p *PathSpec) RelURL(in string, addLanguage bool) string { - baseURL := viper.GetString("BaseURL") + baseURL := viper.GetString("baseURL") canonifyURLs := p.canonifyURLs if (!strings.HasPrefix(in, baseURL) && strings.HasPrefix(in, "http")) || strings.HasPrefix(in, "//") { return in diff --git a/helpers/url_test.go b/helpers/url_test.go index 5394e9573..4072b40e2 100644 --- a/helpers/url_test.go +++ b/helpers/url_test.go @@ -62,10 +62,10 @@ func TestAbsURL(t *testing.T) { func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) { viper.Reset() - viper.Set("Multilingual", multilingual) - viper.Set("CurrentContentLanguage", NewLanguage(lang)) - viper.Set("DefaultContentLanguage", "en") - viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir) + viper.Set("multilingual", multilingual) + viper.Set("currentContentLanguage", NewLanguage(lang)) + viper.Set("defaultContentLanguage", "en") + viper.Set("defaultContentLanguageInSubdir", defaultInSubDir) tests := []struct { input string @@ -86,7 +86,7 @@ func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, } for _, test := range tests { - viper.Set("BaseURL", test.baseURL) + viper.Set("baseURL", test.baseURL) p := NewPathSpecFromConfig(viper.GetViper()) output := p.AbsURL(test.input, addLanguage) expected := test.expected @@ -136,10 +136,10 @@ func TestRelURL(t *testing.T) { func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, lang string) { viper.Reset() - viper.Set("Multilingual", multilingual) - viper.Set("CurrentContentLanguage", NewLanguage(lang)) - viper.Set("DefaultContentLanguage", "en") - viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir) + viper.Set("multilingual", multilingual) + viper.Set("currentContentLanguage", NewLanguage(lang)) + viper.Set("defaultContentLanguage", "en") + viper.Set("defaultContentLanguageInSubdir", defaultInSubDir) tests := []struct { input string @@ -162,7 +162,7 @@ func doTestRelURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool, } for i, test := range tests { - viper.Set("BaseURL", test.baseURL) + viper.Set("baseURL", test.baseURL) viper.Set("canonifyURLs", test.canonify) p := NewPathSpecFromConfig(viper.GetViper()) diff --git a/hugofs/fs.go b/hugofs/fs.go index fff0c64a6..7f8abd337 100644 --- a/hugofs/fs.go +++ b/hugofs/fs.go @@ -81,7 +81,7 @@ func InitFs(fs afero.Fs) { } func initSourceDependencies() { - workingDir := viper.GetString("WorkingDir") + workingDir := viper.GetString("workingDir") if workingDir != "" { workingDirFs = afero.NewBasePathFs(afero.NewReadOnlyFs(sourceFs), workingDir).(*afero.BasePathFs) diff --git a/hugofs/fs_test.go b/hugofs/fs_test.go index 8a68039f7..55007009f 100644 --- a/hugofs/fs_test.go +++ b/hugofs/fs_test.go @@ -14,10 +14,11 @@ package hugofs import ( + "testing" + "github.com/spf13/afero" "github.com/spf13/viper" "github.com/stretchr/testify/assert" - "testing" ) func TestInitDefault(t *testing.T) { @@ -71,7 +72,7 @@ func TestWorkingDir(t *testing.T) { viper.Reset() defer viper.Reset() - viper.Set("WorkingDir", "/a/b/") + viper.Set("workingDir", "/a/b/") InitMemFs() diff --git a/hugolib/config.go b/hugolib/config.go index 86c35964c..2dfe128a6 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -53,57 +53,57 @@ func LoadGlobalConfig(relativeSourcePath, configFilename string) error { func loadDefaultSettings() { viper.SetDefault("cleanDestinationDir", false) - viper.SetDefault("Watch", false) - viper.SetDefault("MetaDataFormat", "toml") - viper.SetDefault("Disable404", false) - viper.SetDefault("DisableRSS", false) - viper.SetDefault("DisableSitemap", false) - viper.SetDefault("DisableRobotsTXT", false) - viper.SetDefault("ContentDir", "content") - viper.SetDefault("LayoutDir", "layouts") - viper.SetDefault("StaticDir", "static") - viper.SetDefault("ArchetypeDir", "archetypes") - viper.SetDefault("PublishDir", "public") - viper.SetDefault("DataDir", "data") - viper.SetDefault("I18nDir", "i18n") - viper.SetDefault("ThemesDir", "themes") - viper.SetDefault("DefaultLayout", "post") - viper.SetDefault("BuildDrafts", false) - viper.SetDefault("BuildFuture", false) - viper.SetDefault("BuildExpired", false) - viper.SetDefault("UglyURLs", false) - viper.SetDefault("Verbose", false) - viper.SetDefault("IgnoreCache", false) - viper.SetDefault("CanonifyURLs", false) - viper.SetDefault("RelativeURLs", false) - viper.SetDefault("RemovePathAccents", false) - viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"}) - viper.SetDefault("Permalinks", make(PermalinkOverrides, 0)) - viper.SetDefault("Sitemap", Sitemap{Priority: -1, Filename: "sitemap.xml"}) - viper.SetDefault("DefaultExtension", "html") - viper.SetDefault("PygmentsStyle", "monokai") - viper.SetDefault("PygmentsUseClasses", false) - viper.SetDefault("PygmentsCodeFences", false) - viper.SetDefault("PygmentsOptions", "") - viper.SetDefault("DisableLiveReload", false) - viper.SetDefault("PluralizeListTitles", true) - viper.SetDefault("PreserveTaxonomyNames", false) - viper.SetDefault("ForceSyncStatic", false) - viper.SetDefault("FootnoteAnchorPrefix", "") - viper.SetDefault("FootnoteReturnLinkContents", "") - viper.SetDefault("NewContentEditor", "") - viper.SetDefault("Paginate", 10) - viper.SetDefault("PaginatePath", "page") - viper.SetDefault("Blackfriday", helpers.NewBlackfriday(viper.GetViper())) - viper.SetDefault("RSSUri", "index.xml") - viper.SetDefault("SectionPagesMenu", "") - viper.SetDefault("DisablePathToLower", false) - viper.SetDefault("HasCJKLanguage", false) - viper.SetDefault("EnableEmoji", false) - viper.SetDefault("PygmentsCodeFencesGuessSyntax", false) - viper.SetDefault("UseModTimeAsFallback", false) - viper.SetDefault("CurrentContentLanguage", helpers.NewDefaultLanguage()) - viper.SetDefault("DefaultContentLanguage", "en") - viper.SetDefault("DefaultContentLanguageInSubdir", false) - viper.SetDefault("EnableMissingTranslationPlaceholders", false) + viper.SetDefault("watch", false) + viper.SetDefault("metaDataFormat", "toml") + viper.SetDefault("disable404", false) + viper.SetDefault("disableRSS", false) + viper.SetDefault("disableSitemap", false) + viper.SetDefault("disableRobotsTXT", false) + viper.SetDefault("contentDir", "content") + viper.SetDefault("layoutDir", "layouts") + viper.SetDefault("staticDir", "static") + viper.SetDefault("archetypeDir", "archetypes") + viper.SetDefault("publishDir", "public") + viper.SetDefault("dataDir", "data") + viper.SetDefault("i18nDir", "i18n") + viper.SetDefault("themesDir", "themes") + viper.SetDefault("defaultLayout", "post") + viper.SetDefault("buildDrafts", false) + viper.SetDefault("buildFuture", false) + viper.SetDefault("buildExpired", false) + viper.SetDefault("uglyURLs", false) + viper.SetDefault("verbose", false) + viper.SetDefault("ignoreCache", false) + viper.SetDefault("canonifyURLs", false) + viper.SetDefault("relativeURLs", false) + viper.SetDefault("removePathAccents", false) + viper.SetDefault("taxonomies", map[string]string{"tag": "tags", "category": "categories"}) + viper.SetDefault("permalinks", make(PermalinkOverrides, 0)) + viper.SetDefault("sitemap", Sitemap{Priority: -1, Filename: "sitemap.xml"}) + viper.SetDefault("defaultExtension", "html") + viper.SetDefault("pygmentsStyle", "monokai") + viper.SetDefault("pygmentsUseClasses", false) + viper.SetDefault("pygmentsCodeFences", false) + viper.SetDefault("pygmentsOptions", "") + viper.SetDefault("disableLiveReload", false) + viper.SetDefault("pluralizeListTitles", true) + viper.SetDefault("preserveTaxonomyNames", false) + viper.SetDefault("forceSyncStatic", false) + viper.SetDefault("footnoteAnchorPrefix", "") + viper.SetDefault("footnoteReturnLinkContents", "") + viper.SetDefault("newContentEditor", "") + viper.SetDefault("paginate", 10) + viper.SetDefault("paginatePath", "page") + viper.SetDefault("blackfriday", helpers.NewBlackfriday(viper.GetViper())) + viper.SetDefault("rSSUri", "index.xml") + viper.SetDefault("sectionPagesMenu", "") + viper.SetDefault("disablePathToLower", false) + viper.SetDefault("hasCJKLanguage", false) + viper.SetDefault("enableEmoji", false) + viper.SetDefault("pygmentsCodeFencesGuessSyntax", false) + viper.SetDefault("useModTimeAsFallback", false) + viper.SetDefault("currentContentLanguage", helpers.NewDefaultLanguage()) + viper.SetDefault("defaultContentLanguage", "en") + viper.SetDefault("defaultContentLanguageInSubdir", false) + viper.SetDefault("enableMissingTranslationPlaceholders", false) } diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 8c307bd25..6a2325fc9 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -35,5 +35,5 @@ func TestLoadGlobalConfig(t *testing.T) { require.NoError(t, LoadGlobalConfig("", "hugo.toml")) assert.Equal(t, "side", helpers.Config().GetString("paginatePath")) // default - assert.Equal(t, "layouts", viper.GetString("LayoutDir")) + assert.Equal(t, "layouts", viper.GetString("layoutDir")) } diff --git a/hugolib/embedded_shortcodes_test.go b/hugolib/embedded_shortcodes_test.go index e2d2f6d2e..f5f4d1eeb 100644 --- a/hugolib/embedded_shortcodes_test.go +++ b/hugolib/embedded_shortcodes_test.go @@ -81,8 +81,8 @@ func TestShortcodeHighlight(t *testing.T) { if !helpers.HasPygments() { t.Skip("Skip test as Pygments is not installed") } - viper.Set("PygmentsStyle", "bw") - viper.Set("PygmentsUseClasses", false) + viper.Set("pygmentsStyle", "bw") + viper.Set("pygmentsUseClasses", false) for i, this := range []struct { in, expected string @@ -311,7 +311,7 @@ func TestShortcodeTweet(t *testing.T) { templ.Lookup("").Funcs(tweetFuncMap) 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) output, err := HandleShortcodes(this.in, p, templ) diff --git a/hugolib/handler_page.go b/hugolib/handler_page.go index c1f83d716..c71936954 100644 --- a/hugolib/handler_page.go +++ b/hugolib/handler_page.go @@ -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 // process a page in isolation. See the new preRender func. - if viper.GetBool("EnableEmoji") { + if viper.GetBool("enableEmoji") { p.rawContent = helpers.Emojify(p.rawContent) } diff --git a/hugolib/handler_test.go b/hugolib/handler_test.go index 0e59510d3..ba5daa8c2 100644 --- a/hugolib/handler_test.go +++ b/hugolib/handler_test.go @@ -40,7 +40,7 @@ func TestDefaultHandler(t *testing.T) { {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) s := &Site{ diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index ae31132c3..b96a13bbf 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -73,7 +73,7 @@ func NewHugoSitesFromConfiguration() (*HugoSites, error) { func createSitesFromConfig() ([]*Site, error) { var sites []*Site - multilingual := viper.GetStringMap("Languages") + multilingual := viper.GetStringMap("languages") if len(multilingual) == 0 { sites = append(sites, newSite(helpers.NewDefaultLanguage())) } @@ -339,12 +339,12 @@ func (h *HugoSites) render() error { return nil } - if viper.GetBool("DisableSitemap") { + if viper.GetBool("disableSitemap") { return nil } // TODO(bep) DRY - sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap")) + sitemapDefault := parseSitemap(viper.GetStringMap("sitemap")) s := h.Sites[0] diff --git a/hugolib/hugo_sites_test.go b/hugolib/hugo_sites_test.go index dbbcd0277..66c818acf 100644 --- a/hugolib/hugo_sites_test.go +++ b/hugolib/hugo_sites_test.go @@ -40,7 +40,7 @@ func testCommonResetState() { loadDefaultSettings() // 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 { panic("Content folder creation failed.") @@ -56,7 +56,7 @@ func TestMultiSitesMainLangInRoot(t *testing.T) { func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) { testCommonResetState() - viper.Set("DefaultContentLanguageInSubdir", defaultInSubDir) + viper.Set("defaultContentLanguageInSubdir", defaultInSubDir) siteConfig := testSiteConfig{DefaultContentLanguage: "fr"} sites := createMultiTestSites(t, siteConfig, multiSiteTOMLConfigTemplate) @@ -155,7 +155,7 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) { } func replaceDefaultContentLanguageValue(value string, defaultInSubDir bool) string { - replace := viper.GetString("DefaultContentLanguage") + "/" + replace := viper.GetString("defaultContentLanguage") + "/" if !defaultInSubDir { value = strings.Replace(value, replace, "", 1) @@ -639,7 +639,7 @@ title = "Svenska" func TestChangeDefaultLanguage(t *testing.T) { testCommonResetState() - viper.Set("DefaultContentLanguageInSubdir", false) + viper.Set("defaultContentLanguageInSubdir", false) sites := createMultiTestSites(t, testSiteConfig{DefaultContentLanguage: "fr"}, multiSiteTOMLConfigTemplate) cfg := BuildCfg{} @@ -771,14 +771,14 @@ var tocPageWithShortcodesInHeadingsExpected = `<nav id="TableOfContents"> </nav>` var multiSiteTOMLConfigTemplate = ` -DefaultExtension = "html" -baseurl = "http://example.com/blog" -DisableSitemap = false -DisableRSS = false -RSSUri = "index.xml" +defaultExtension = "html" +baseURL = "http://example.com/blog" +disableSitemap = false +disableRSS = false +rssURI = "index.xml" paginate = 1 -DefaultContentLanguage = "{{ .DefaultContentLanguage }}" +defaultContentLanguage = "{{ .DefaultContentLanguage }}" [permalinks] other = "/somewhere/else/:filename" @@ -830,14 +830,14 @@ lag = "lag" ` var multiSiteYAMLConfig = ` -DefaultExtension: "html" -baseurl: "http://example.com/blog" -DisableSitemap: false -DisableRSS: false -RSSUri: "index.xml" +defaultExtension: "html" +baseURL: "http://example.com/blog" +disableSitemap: false +disableRSS: false +rssURI: "index.xml" paginate: 1 -DefaultContentLanguage: "fr" +defaultContentLanguage: "fr" permalinks: other: "/somewhere/else/:filename" @@ -890,13 +890,13 @@ Languages: var multiSiteJSONConfig = ` { - "DefaultExtension": "html", - "baseurl": "http://example.com/blog", - "DisableSitemap": false, - "DisableRSS": false, - "RSSUri": "index.xml", + "defaultExtension": "html", + "baseURL": "http://example.com/blog", + "disableSitemap": false, + "disableRSS": false, + "rssURI": "index.xml", "paginate": 1, - "DefaultContentLanguage": "fr", + "defaultContentLanguage": "fr", "permalinks": { "other": "/somewhere/else/:filename" }, @@ -1080,7 +1080,7 @@ publishdate: "2000-01-05" --- # doc4 *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' `)}, {Name: filepath.FromSlash("other/doc5.fr.md"), Content: []byte(`--- diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index 5ca8af8e5..38bcd1c05 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -376,7 +376,7 @@ func TestMenuWithUnicodeURLs(t *testing.T) { func doTestMenuWithUnicodeURLs(t *testing.T, canonifyURLs bool) { testCommonResetState() - viper.Set("CanonifyURLs", canonifyURLs) + viper.Set("canonifyURLs", canonifyURLs) s := setupMenuTests(t, menuPageSources) @@ -398,12 +398,12 @@ func TestSectionPagesMenu(t *testing.T) { doTestSectionPagesMenu(false, t) } -func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) { +func doTestSectionPagesMenu(canonifyURLs bool, t *testing.T) { testCommonResetState() - viper.Set("SectionPagesMenu", "spm") + viper.Set("sectionPagesMenu", "spm") - viper.Set("CanonifyURLs", canonifyUrls) + viper.Set("canonifyURLs", canonifyURLs) s := setupMenuTests(t, menuPageSectionsSources) assert.Equal(t, 3, len(s.Sections)) @@ -459,7 +459,7 @@ func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) { func TestTaxonomyNodeMenu(t *testing.T) { testCommonResetState() - viper.Set("CanonifyURLs", true) + viper.Set("canonifyURLs", true) s := setupMenuTests(t, menuPageSources) for i, this := range []struct { @@ -544,8 +544,8 @@ func TestMenuSortByN(t *testing.T) { func TestHomeNodeMenu(t *testing.T) { testCommonResetState() - viper.Set("CanonifyURLs", true) - viper.Set("UglyURLs", true) + viper.Set("canonifyURLs", true) + viper.Set("uglyURLs", true) s := setupMenuTests(t, menuPageSources) @@ -660,11 +660,11 @@ func setupTestMenuState(t *testing.T) { menus, err := tomlToMap(confMenu1) 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("baseurl", "http://foo.local/Zoo/") + viper.Set("baseURL", "http://foo.local/Zoo/") } func setupMenuTests(t *testing.T, pageSources []source.ByteSource) *Site { diff --git a/hugolib/page.go b/hugolib/page.go index 484425697..f16e5ea33 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -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) } else { 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 { 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 != "" { return p.extension } - return viper.GetString("DefaultExtension") + return viper.GetString("defaultExtension") } // AllTranslations returns all translations, including the current Page. @@ -637,8 +637,8 @@ func (p *Page) LinkTitle() string { } func (p *Page) shouldBuild() bool { - return shouldBuild(viper.GetBool("BuildFuture"), viper.GetBool("BuildExpired"), - viper.GetBool("BuildDrafts"), p.Draft, p.PublishDate, p.ExpiryDate) + return shouldBuild(viper.GetBool("buildFuture"), viper.GetBool("buildExpired"), + viper.GetBool("buildDrafts"), p.Draft, p.PublishDate, p.ExpiryDate) } func shouldBuild(buildFuture bool, buildExpired bool, buildDrafts bool, Draft bool, @@ -697,7 +697,7 @@ func (p *Page) RelPermalink() (string, error) { 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 // have to return the URL relative from 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 } - if p.Date.IsZero() && viper.GetBool("UseModTimeAsFallback") { - fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), p.File.Path())) + if p.Date.IsZero() && viper.GetBool("useModTimeAsFallback") { + fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("contentDir")), p.File.Path())) if err == nil { p.Date = fi.ModTime() } @@ -855,7 +855,7 @@ func (p *Page) update(f interface{}) error { if isCJKLanguage != nil { p.isCJKLanguage = *isCJKLanguage - } else if viper.GetBool("HasCJKLanguage") { + } else if viper.GetBool("hasCJKLanguage") { if cjk.Match(p.rawContent) { p.isCJKLanguage = true } else { diff --git a/hugolib/page_permalink_test.go b/hugolib/page_permalink_test.go index eb3a6c878..fd8f11dda 100644 --- a/hugolib/page_permalink_test.go +++ b/hugolib/page_permalink_test.go @@ -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/"}, } - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") for i, test := range tests { - viper.Set("uglyurls", test.uglyURLs) - viper.Set("canonifyurls", test.canonifyURLs) + viper.Set("uglyURLs", test.uglyURLs) + viper.Set("canonifyURLs", test.canonifyURLs) info := newSiteInfo(siteBuilderCfg{baseURL: string(test.base), language: helpers.NewDefaultLanguage()}) p := &Page{ diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 342ff3bd5..16437d0f3 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -830,7 +830,7 @@ func TestWordCountWithAllCJKRunesWithoutHasCJKLanguage(t *testing.T) { func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) { testCommonResetState() - viper.Set("HasCJKLanguage", true) + viper.Set("hasCJKLanguage", true) assertFunc := func(t *testing.T, ext string, pages Pages) { p := pages[0] @@ -844,7 +844,7 @@ func TestWordCountWithAllCJKRunesHasCJKLanguage(t *testing.T) { func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) { testCommonResetState() - viper.Set("HasCJKLanguage", true) + viper.Set("hasCJKLanguage", true) assertFunc := func(t *testing.T, ext string, pages Pages) { p := pages[0] @@ -863,7 +863,7 @@ func TestWordCountWithMainEnglishWithCJKRunes(t *testing.T) { func TestWordCountWithIsCJKLanguageFalse(t *testing.T) { testCommonResetState() - viper.Set("HasCJKLanguage", true) + viper.Set("hasCJKLanguage", true) assertFunc := func(t *testing.T, ext string, pages Pages) { p := pages[0] @@ -1099,7 +1099,7 @@ func TestSliceToLower(t *testing.T) { func TestPagePaths(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") siteParmalinksSetting := PermalinkOverrides{ "post": ":year/:month/:day/:title/", } diff --git a/hugolib/pagination_test.go b/hugolib/pagination_test.go index 7bbc38058..7b599a80b 100644 --- a/hugolib/pagination_test.go +++ b/hugolib/pagination_test.go @@ -195,7 +195,7 @@ func doTestPagerNoPages(t *testing.T, paginator *paginator) { func TestPaginationURLFactory(t *testing.T) { testCommonResetState() - viper.Set("PaginatePath", "zoo") + viper.Set("paginatePath", "zoo") unicode := newPaginationURLFactory("новости проекта") fooBar := newPaginationURLFactory("foo", "bar") diff --git a/hugolib/robotstxt_test.go b/hugolib/robotstxt_test.go index 5b6c90826..2faabda7b 100644 --- a/hugolib/robotstxt_test.go +++ b/hugolib/robotstxt_test.go @@ -34,7 +34,7 @@ func TestRobotsTXTOutput(t *testing.T) { hugofs.InitMemFs() - viper.Set("baseurl", "http://auth/bub/") + viper.Set("baseURL", "http://auth/bub/") viper.Set("enableRobotsTXT", true) s := &Site{ @@ -54,6 +54,6 @@ func TestRobotsTXTOutput(t *testing.T) { robots := helpers.ReaderToBytes(robotsFile) 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) } } diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go index f0ab1c2c3..2bf849f9e 100644 --- a/hugolib/rss_test.go +++ b/hugolib/rss_test.go @@ -45,8 +45,8 @@ func TestRSSOutput(t *testing.T) { testCommonResetState() rssURI := "public/customrss.xml" - viper.Set("baseurl", "http://auth/bub/") - viper.Set("RSSUri", rssURI) + viper.Set("baseURL", "http://auth/bub/") + viper.Set("rssURI", rssURI) for _, s := range weightedSources { writeSource(t, filepath.Join("content", s.Name), string(s.Content)) diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go index 54abdecd9..b2685e2ec 100644 --- a/hugolib/shortcode_test.go +++ b/hugolib/shortcode_test.go @@ -305,8 +305,8 @@ func TestHighlight(t *testing.T) { if !helpers.HasPygments() { t.Skip("Skip test as Pygments is not installed") } - viper.Set("PygmentsStyle", "bw") - viper.Set("PygmentsUseClasses", false) + viper.Set("pygmentsStyle", "bw") + viper.Set("pygmentsUseClasses", false) templ := tpl.New() @@ -455,14 +455,14 @@ func TestShortcodesInSite(t *testing.T) { testCommonResetState() baseURL := "http://foo/bar" - viper.Set("DefaultExtension", "html") - viper.Set("DefaultContentLanguage", "en") - viper.Set("baseurl", baseURL) - viper.Set("UglyURLs", false) + viper.Set("defaultExtension", "html") + viper.Set("defaultContentLanguage", "en") + viper.Set("baseURL", baseURL) + viper.Set("uglyURLs", false) viper.Set("verbose", true) - viper.Set("pygmentsuseclasses", true) - viper.Set("pygmentscodefences", true) + viper.Set("pygmentsUseClasses", true) + viper.Set("pygmentsCodefences", true) tests := []struct { contentPath string diff --git a/hugolib/site.go b/hugolib/site.go index 7f96bb5aa..b094142af 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -819,8 +819,8 @@ func (s *Site) setupPrevNext() { func (s *Site) setCurrentLanguageConfig() error { // There are sadly some global template funcs etc. that need the language information. - viper.Set("Multilingual", s.multilingualEnabled()) - viper.Set("CurrentContentLanguage", s.Language) + viper.Set("multilingual", s.multilingualEnabled()) + viper.Set("currentContentLanguage", s.Language) // Cache the current config. helpers.InitConfigProviderForCurrentContentLanguage() return tpl.SetTranslateLang(s.Language) @@ -886,7 +886,7 @@ func (s *Site) initialize() (err error) { return err } - staticDir := helpers.AbsPathify(viper.GetString("StaticDir") + "/") + staticDir := helpers.AbsPathify(viper.GetString("staticDir") + "/") s.Source = &source.Filesystem{ AvoidPaths: []string{staticDir}, @@ -907,7 +907,7 @@ func (s *SiteInfo) HomeAbsURL() string { // SitemapAbsURL is a convenience method giving the absolute URL to the sitemap. func (s *SiteInfo) SitemapAbsURL() string { - sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap")) + sitemapDefault := parseSitemap(viper.GetStringMap("sitemap")) p := s.HomeAbsURL() if !strings.HasSuffix(p, "/") { p += "/" @@ -930,12 +930,12 @@ func (s *Site) initializeSiteInfo() { params := lang.Params() permalinks := make(PermalinkOverrides) - for k, v := range viper.GetStringMapString("Permalinks") { + for k, v := range viper.GetStringMapString("permalinks") { permalinks[k] = pathPattern(v) } - defaultContentInSubDir := viper.GetBool("DefaultContentLanguageInSubdir") - defaultContentLanguage := viper.GetString("DefaultContentLanguage") + defaultContentInSubDir := viper.GetBool("defaultContentLanguageInSubdir") + defaultContentLanguage := viper.GetString("defaultContentLanguage") languagePrefix := "" if s.multilingualEnabled() && (defaultContentInSubDir || lang.Lang != defaultContentLanguage) { @@ -948,22 +948,22 @@ func (s *Site) initializeSiteInfo() { } s.Info = SiteInfo{ - BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))), - Title: lang.GetString("Title"), + BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("baseURL"))), + Title: lang.GetString("title"), Author: lang.GetStringMap("author"), Social: lang.GetStringMapString("social"), - LanguageCode: lang.GetString("languagecode"), + LanguageCode: lang.GetString("languageCode"), Copyright: lang.GetString("copyright"), - DisqusShortname: lang.GetString("DisqusShortname"), + DisqusShortname: lang.GetString("disqusShortname"), multilingual: multilingual, Language: lang, LanguagePrefix: languagePrefix, Languages: languages, defaultContentLanguageInSubdir: defaultContentInSubDir, - GoogleAnalytics: lang.GetString("GoogleAnalytics"), - BuildDrafts: viper.GetBool("BuildDrafts"), - canonifyURLs: viper.GetBool("CanonifyURLs"), - preserveTaxonomyNames: lang.GetBool("PreserveTaxonomyNames"), + GoogleAnalytics: lang.GetString("googleAnalytics"), + BuildDrafts: viper.GetBool("buildDrafts"), + canonifyURLs: viper.GetBool("canonifyURLs"), + preserveTaxonomyNames: lang.GetBool("preserveTaxonomyNames"), AllPages: &s.AllPages, Pages: &s.Pages, rawAllPages: &s.rawAllPages, @@ -984,14 +984,14 @@ func (s *Site) hasTheme() bool { } func (s *Site) dataDir() string { - return viper.GetString("DataDir") + return viper.GetString("dataDir") } func (s *Site) absDataDir() string { return helpers.AbsPathify(s.dataDir()) } func (s *Site) i18nDir() string { - return viper.GetString("I18nDir") + return viper.GetString("i18nDir") } func (s *Site) absI18nDir() string { @@ -1043,7 +1043,7 @@ func (s *Site) absThemeDir() string { } func (s *Site) layoutDir() string { - return viper.GetString("LayoutDir") + return viper.GetString("layoutDir") } func (s *Site) absLayoutDir() string { @@ -1069,7 +1069,7 @@ func (s *Site) getThemeLayoutDir(path string) 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 { @@ -1105,7 +1105,7 @@ func getRealDir(base, path string) string { } func (s *Site) absPublishDir() string { - return helpers.AbsPathify(viper.GetString("PublishDir")) + return helpers.AbsPathify(viper.GetString("publishDir")) } func (s *Site) checkDirectories() (err error) { @@ -1756,7 +1756,7 @@ func (s *Site) renderTaxonomiesLists(prepare bool) error { go errorCollator(results, errs) - taxonomies := s.Language.GetStringMapString("Taxonomies") + taxonomies := s.Language.GetStringMapString("taxonomies") for singular, plural := range taxonomies { for key, pages := range s.Taxonomies[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"}) dest := base - if viper.GetBool("UglyURLs") { + if viper.GetBool("uglyURLs") { dest = helpers.Uglify(baseWithLanguagePrefix + ".html") } else { dest = helpers.PrettifyPath(baseWithLanguagePrefix + "/index.html") @@ -1880,16 +1880,16 @@ func taxonomyRenderer(prepare bool, s *Site, taxes <-chan taxRenderInfo, results continue } - if !viper.GetBool("DisableRSS") { + if !viper.GetBool("disableRSS") { // XML Feed rssNode := s.newNode(fmt.Sprintf("%s-%s-rss", t.plural, t.key)) - rssuri := viper.GetString("RSSUri") - s.setURLs(rssNode, base+"/"+rssuri) + rssURI := viper.GetString("rssURI") + s.setURLs(rssNode, base+"/"+rssURI) rssNode.Data = n.Data 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 continue } @@ -1936,7 +1936,7 @@ func (s *Site) newSectionListNode(prepare bool, sectionName, section string, dat } sectionName = helpers.FirstUpper(sectionName) - if viper.GetBool("PluralizeListTitles") { + if viper.GetBool("pluralizeListTitles") { n.Title = inflect.Pluralize(sectionName) } else { n.Title = sectionName @@ -2012,13 +2012,13 @@ func (s *Site) renderSectionLists(prepare bool) error { return nil } - if !viper.GetBool("DisableRSS") && section != "" { + if !viper.GetBool("disableRSS") && section != "" { // XML Feed - rssuri := viper.GetString("RSSUri") + rssURI := viper.GetString("rssURI") 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"} - 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 } } @@ -2076,10 +2076,10 @@ func (s *Site) renderHomePage(prepare bool) error { } } - if !viper.GetBool("DisableRSS") { + if !viper.GetBool("disableRSS") { // XML Feed rssNode := s.newNode("rss-home") - s.setURLs(rssNode, viper.GetString("RSSUri")) + s.setURLs(rssNode, viper.GetString("rssURI")) rssNode.Title = "" high := 50 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"} - 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 } } - if viper.GetBool("Disable404") { + if viper.GetBool("disable404") { return nil } @@ -2138,11 +2138,11 @@ func (s *Site) newPage() *Page { } func (s *Site) renderSitemap() error { - if viper.GetBool("DisableSitemap") { + if viper.GetBool("disableSitemap") { return nil } - sitemapDefault := parseSitemap(viper.GetStringMap("Sitemap")) + sitemapDefault := parseSitemap(viper.GetStringMap("sitemap")) n := s.newNode("sitemap") @@ -2183,7 +2183,7 @@ func (s *Site) renderSitemap() error { } func (s *Site) renderRobotsTXT() error { - if !viper.GetBool("EnableRobotsTXT") { + if !viper.GetBool("enableRobotsTXT") { return nil } @@ -2232,7 +2232,7 @@ func (s *SiteInfo) permalink(plink string) string { func (s *SiteInfo) permalinkStr(plink string) string { return helpers.MakePermalink( - viper.GetString("BaseURL"), + viper.GetString("baseURL"), s.pathSpec.URLizeAndPrep(plink)).String() } @@ -2323,10 +2323,10 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout defer bp.PutBuffer(outBuffer) var path []byte - if viper.GetBool("RelativeURLs") { + if viper.GetBool("relativeURLs") { path = []byte(helpers.GetDottedRelativePath(dest)) } else { - s := viper.GetString("BaseURL") + s := viper.GetString("baseURL") if !strings.HasSuffix(s, "/") { s += "/" } @@ -2364,31 +2364,31 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou transformLinks := transform.NewEmptyTransforms() - if viper.GetBool("RelativeURLs") || viper.GetBool("CanonifyURLs") { + if viper.GetBool("relativeURLs") || viper.GetBool("canonifyURLs") { 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) } // For performance reasons we only inject the Hugo generator tag on the home page. if n, ok := d.(*Node); ok && n.IsHome { - if !viper.GetBool("DisableHugoGeneratorInject") { + if !viper.GetBool("disableHugoGeneratorInject") { transformLinks = append(transformLinks, transform.HugoGeneratorInject) } } var path []byte - if viper.GetBool("RelativeURLs") { + if viper.GetBool("relativeURLs") { translated, err := pageTarget.(target.OptionalTranslator).TranslateRelative(dest) if err != nil { return err } path = []byte(helpers.GetDottedRelativePath(translated)) - } else if viper.GetBool("CanonifyURLs") { - s := viper.GetString("BaseURL") + } else if viper.GetBool("canonifyURLs") { + s := viper.GetString("baseURL") if !strings.HasSuffix(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) if dest == "/" { debugAddend := "" - if !viper.GetBool("Verbose") { + if !viper.GetBool("verbose") { debugAddend = "* For more debugging information, run \"hugo -v\"" } distinctFeedbackLogger.Printf(`============================================================= @@ -2413,7 +2413,7 @@ Your rendered home page is blank: /index.html is zero-length %s =============================================================`, filepath.Base(viper.ConfigFileUsed()), - viper.GetString("Theme"), + viper.GetString("theme"), debugAddend) } @@ -2499,7 +2499,7 @@ func (s *Site) initTargetList() { if s.targets.page == nil { s.targets.page = &target.PagePub{ PublishDir: s.absPublishDir(), - UglyURLs: viper.GetBool("UglyURLs"), + UglyURLs: viper.GetBool("uglyURLs"), } } 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) { - if viper.GetBool("RelativeURLs") { + if viper.GetBool("relativeURLs") { // 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) { permalink = "/" + strings.TrimPrefix(permalink, baseURL) } @@ -2572,7 +2572,7 @@ func (s *Site) draftStats() string { msg = fmt.Sprintf("%d drafts rendered", s.draftCount) } - if viper.GetBool("BuildDrafts") { + if viper.GetBool("buildDrafts") { 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) } - if viper.GetBool("BuildFuture") { + if viper.GetBool("buildFuture") { 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) } - if viper.GetBool("BuildExpired") { + if viper.GetBool("buildExpired") { return fmt.Sprintf("%d of ", s.expiredCount) + msg } diff --git a/hugolib/site_show_plan_test.go b/hugolib/site_show_plan_test.go index db5bec7b6..23ae9c190 100644 --- a/hugolib/site_show_plan_test.go +++ b/hugolib/site_show_plan_test.go @@ -83,7 +83,7 @@ func _TestDegenerateNoTarget(t *testing.T) { func _TestFileTarget(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") s := &Site{ Source: &source.InMemorySource{ByteSource: fakeSource}, @@ -104,8 +104,8 @@ func _TestFileTarget(t *testing.T) { func _TestPageTargetUgly(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") - viper.Set("UglyURLs", true) + viper.Set("defaultExtension", "html") + viper.Set("uglyURLs", true) s := &Site{ targets: targetList{page: &target.PagePub{UglyURLs: true, PublishDir: "public"}}, @@ -129,7 +129,7 @@ func _TestPageTargetUgly(t *testing.T) { func _TestFileTargetPublishDir(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") s := &Site{ diff --git a/hugolib/site_test.go b/hugolib/site_test.go index 9cf094e19..1792263e3 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -56,9 +56,9 @@ func init() { func TestReadPagesFromSourceWithEmptySource(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") viper.Set("verbose", true) - viper.Set("baseurl", "http://auth/bub") + viper.Set("baseURL", "http://auth/bub") sources := []source.ByteSource{} @@ -143,7 +143,7 @@ func TestDraftAndFutureRender(t *testing.T) { 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 s := siteSetup(t) @@ -152,31 +152,31 @@ func TestDraftAndFutureRender(t *testing.T) { } // only publishDate in the past should be rendered - viper.Set("BuildDrafts", true) + viper.Set("buildDrafts", true) s = siteSetup(t) if len(s.AllPages) != 2 { t.Fatal("Future Dated Posts published unexpectedly") } // drafts should not be rendered, but all dates should - viper.Set("BuildDrafts", false) - viper.Set("BuildFuture", true) + viper.Set("buildDrafts", false) + viper.Set("buildFuture", true) s = siteSetup(t) if len(s.AllPages) != 2 { t.Fatal("Draft posts published unexpectedly") } // all 4 should be included - viper.Set("BuildDrafts", true) - viper.Set("BuildFuture", true) + viper.Set("buildDrafts", true) + viper.Set("buildFuture", true) s = siteSetup(t) if len(s.AllPages) != 4 { t.Fatal("Drafts or Future posts not included as expected") } //setting defaults back - viper.Set("BuildDrafts", false) - viper.Set("BuildFuture", false) + viper.Set("buildDrafts", false) + viper.Set("buildFuture", false) } func TestFutureExpirationRender(t *testing.T) { @@ -201,7 +201,7 @@ func TestFutureExpirationRender(t *testing.T) { return s } - viper.Set("baseurl", "http://auth/bub") + viper.Set("baseURL", "http://auth/bub") s := siteSetup(t) @@ -233,9 +233,9 @@ func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) { testCommonResetState() baseURL := "http://foo/bar" - viper.Set("DefaultExtension", "html") - viper.Set("baseurl", baseURL) - viper.Set("UglyURLs", uglyURLs) + viper.Set("defaultExtension", "html") + viper.Set("baseURL", baseURL) + viper.Set("uglyURLs", uglyURLs) viper.Set("verbose", true) 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. { Name: filepath.FromSlash("sect/doc2.md"), - Content: []byte(fmt.Sprintf(`**Ref 1:** + Content: []byte(fmt.Sprintf(`**Ref 1:** {{< %s "sect/doc1.md" >}} @@ -330,18 +330,18 @@ func TestShouldAlwaysHaveUglyURLs(t *testing.T) { func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") viper.Set("verbose", true) - viper.Set("baseurl", "http://auth/bub") - viper.Set("DisableSitemap", false) - viper.Set("DisableRSS", false) - viper.Set("RSSUri", "index.xml") + viper.Set("baseURL", "http://auth/bub") + viper.Set("disableSitemap", false) + viper.Set("disableRSS", false) + viper.Set("rssURI", "index.xml") viper.Set("blackfriday", // TODO(bep) https://github.com/spf13/viper/issues/261 map[string]interface{}{ strings.ToLower("plainIDAnchors"): true}) - viper.Set("UglyURLs", uglyURLs) + viper.Set("uglyURLs", uglyURLs) sources := []source.ByteSource{ {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() testCommonResetState() - viper.Set("baseurl", "http://auth/sub/") - viper.Set("DefaultExtension", "html") - viper.Set("UglyURLs", uglify) - viper.Set("PluralizeListTitles", pluralize) - viper.Set("CanonifyURLs", canonify) + viper.Set("baseURL", "http://auth/sub/") + viper.Set("defaultExtension", "html") + viper.Set("uglyURLs", uglify) + viper.Set("pluralizeListTitles", pluralize) + viper.Set("canonifyURLs", canonify) 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*")}, } - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") viper.Set("verbose", true) - viper.Set("CanonifyURLs", true) - viper.Set("baseurl", "http://auth/bub") + viper.Set("canonifyURLs", true) + viper.Set("baseURL", "http://auth/bub") s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, targets: targetList{page: &target.PagePub{UglyURLs: true}}, @@ -539,7 +539,7 @@ func TestSkipRender(t *testing.T) { func TestAbsURLify(t *testing.T) { testCommonResetState() - viper.Set("DefaultExtension", "html") + viper.Set("defaultExtension", "html") hugofs.InitMemFs() sources := []source.ByteSource{ @@ -548,14 +548,14 @@ func TestAbsURLify(t *testing.T) { } for _, baseURL := range []string{"http://auth/bub", "http://base", "//base"} { for _, canonify := range []bool{true, false} { - viper.Set("CanonifyURLs", canonify) - viper.Set("BaseURL", baseURL) + viper.Set("canonifyURLs", canonify) + viper.Set("baseURL", baseURL) s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, targets: targetList{page: &target.PagePub{UglyURLs: true}}, 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 { t.Fatalf("Failed to build site: %s", err) @@ -644,7 +644,7 @@ func TestOrderedPages(t *testing.T) { hugofs.InitMemFs() - viper.Set("baseurl", "http://auth/bub") + viper.Set("baseURL", "http://auth/bub") s := &Site{ Source: &source.InMemorySource{ByteSource: weightedSources}, Language: helpers.NewDefaultLanguage(), @@ -713,7 +713,7 @@ func TestGroupedPages(t *testing.T) { hugofs.InitMemFs() - viper.Set("baseurl", "http://auth/bub") + viper.Set("baseURL", "http://auth/bub") s := &Site{ Source: &source.InMemorySource{ByteSource: groupedSources}, Language: helpers.NewDefaultLanguage(), @@ -897,7 +897,7 @@ func TestWeightedTaxonomies(t *testing.T) { taxonomies["tag"] = "tags" taxonomies["category"] = "categories" - viper.Set("baseurl", "http://auth/bub") + viper.Set("baseURL", "http://auth/bub") viper.Set("taxonomies", taxonomies) s := &Site{ Source: &source.InMemorySource{ByteSource: sources}, @@ -959,11 +959,11 @@ func setupLinkingMockSite(t *testing.T) *Site { {Name: filepath.FromSlash("level2/level3/common.png"), Content: []byte("")}, } - viper.Set("baseurl", "http://auth/") - viper.Set("DefaultExtension", "html") - viper.Set("UglyURLs", false) - viper.Set("PluralizeListTitles", false) - viper.Set("CanonifyURLs", false) + viper.Set("baseURL", "http://auth/") + viper.Set("defaultExtension", "html") + viper.Set("uglyURLs", false) + viper.Set("pluralizeListTitles", false) + viper.Set("canonifyURLs", false) viper.Set("blackfriday", // TODO(bep) see https://github.com/spf13/viper/issues/261 map[string]interface{}{ diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index f53d4492d..9db045492 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -61,7 +61,7 @@ func TestShouldNotAddTrailingSlashToBaseURL(t *testing.T) { {"http://base.com/sub", "http://base.com/sub"}, {"http://base.com", "http://base.com"}} { - viper.Set("BaseURL", this.in) + viper.Set("baseURL", this.in) s := newSiteDefaultLang() s.initializeSiteInfo() @@ -76,7 +76,7 @@ func TestPageCount(t *testing.T) { testCommonResetState() hugofs.InitMemFs() - viper.Set("uglyurls", false) + viper.Set("uglyURLs", false) viper.Set("paginate", 10) s := &Site{ Source: &source.InMemorySource{ByteSource: urlFakeSource}, diff --git a/hugolib/sitemap_test.go b/hugolib/sitemap_test.go index d46c8b05c..0ec51497a 100644 --- a/hugolib/sitemap_test.go +++ b/hugolib/sitemap_test.go @@ -38,7 +38,7 @@ const SITEMAP_TEMPLATE = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap func TestSitemapOutput(t *testing.T) { testCommonResetState() - viper.Set("baseurl", "http://auth/bub/") + viper.Set("baseURL", "http://auth/bub/") s := &Site{ Source: &source.InMemorySource{ByteSource: weightedSources}, diff --git a/source/file.go b/source/file.go index 500da2548..1fd0e2a97 100644 --- a/source/file.go +++ b/source/file.go @@ -128,7 +128,7 @@ func NewFile(relpath string) *File { f.lang = strings.TrimPrefix(filepath.Ext(f.baseName), ".") if f.lang == "" { - f.lang = viper.GetString("DefaultContentLanguage") + f.lang = viper.GetString("defaultContentLanguage") } f.translationBaseName = helpers.Filename(f.baseName) diff --git a/source/filesystem.go b/source/filesystem.go index 5a6e331f1..5b47b7abf 100644 --- a/source/filesystem.go +++ b/source/filesystem.go @@ -159,7 +159,7 @@ func isNonProcessablePath(filePath string) bool { strings.HasSuffix(base, "~") { return true } - ignoreFiles := viper.GetStringSlice("IgnoreFiles") + ignoreFiles := viper.GetStringSlice("ignoreFiles") if len(ignoreFiles) > 0 { for _, ignorePattern := range ignoreFiles { match, err := regexp.MatchString(ignorePattern, filePath) diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go index d24bc7ee8..96a3ea639 100644 --- a/tpl/template_funcs.go +++ b/tpl/template_funcs.go @@ -1278,7 +1278,7 @@ func markdownify(in interface{}) (template.HTML, error) { return "", err } - language := viper.Get("CurrentContentLanguage").(*helpers.Language) + language := viper.Get("currentContentLanguage").(*helpers.Language) m := helpers.RenderBytes(&helpers.RenderingContext{ ConfigProvider: language, diff --git a/tpl/template_funcs_test.go b/tpl/template_funcs_test.go index 071910579..16325a75d 100644 --- a/tpl/template_funcs_test.go +++ b/tpl/template_funcs_test.go @@ -75,9 +75,9 @@ func TestFuncsInTemplate(t *testing.T) { workingDir := "/home/hugo" - viper.Set("WorkingDir", workingDir) - viper.Set("CurrentContentLanguage", helpers.NewDefaultLanguage()) - viper.Set("Multilingual", true) + viper.Set("workingDir", workingDir) + viper.Set("currentContentLanguage", helpers.NewDefaultLanguage()) + viper.Set("multilingual", true) fs := &afero.MemMapFs{} hugofs.InitFs(fs) @@ -1773,7 +1773,7 @@ func TestReturnWhenSet(t *testing.T) { } func TestMarkdownify(t *testing.T) { - viper.Set("CurrentContentLanguage", helpers.NewDefaultLanguage()) + viper.Set("currentContentLanguage", helpers.NewDefaultLanguage()) for i, this := range []struct { in interface{} @@ -2444,7 +2444,7 @@ func TestReadFile(t *testing.T) { workingDir := "/home/hugo" - viper.Set("WorkingDir", workingDir) + viper.Set("workingDir", workingDir) fs := &afero.MemMapFs{} hugofs.InitFs(fs) diff --git a/tpl/template_i18n.go b/tpl/template_i18n.go index 080bfbd54..00cdd7877 100644 --- a/tpl/template_i18n.go +++ b/tpl/template_i18n.go @@ -44,14 +44,14 @@ func SetTranslateLang(language *helpers.Language) error { translator.current = f } else { 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 } func SetI18nTfuncs(bndl *bundle.Bundle) { translator = &translate{translateFuncs: make(map[string]bundle.TranslateFunc)} - defaultContentLanguage := viper.GetString("DefaultContentLanguage") + defaultContentLanguage := viper.GetString("defaultContentLanguage") var ( defaultT bundle.TranslateFunc err error @@ -76,7 +76,7 @@ func SetI18nTfuncs(bndl *bundle.Bundle) { if Logi18nWarnings { i18nWarningLogger.Printf("i18n|MISSING_TRANSLATION|%s|%s", currentLang, translationID) } - if viper.GetBool("EnableMissingTranslationPlaceholders") { + if viper.GetBool("enableMissingTranslationPlaceholders") { return fmt.Sprintf("[i18n] %s", translationID) } if defaultT != nil { diff --git a/tpl/template_i18n_test.go b/tpl/template_i18n_test.go index 29235b462..241217d8a 100644 --- a/tpl/template_i18n_test.go +++ b/tpl/template_i18n_test.go @@ -129,12 +129,12 @@ func doTestI18nTranslate(t *testing.T, data map[string][]byte, lang, id string, func TestI18nTranslate(t *testing.T) { var actual, expected string - viper.SetDefault("DefaultContentLanguage", "en") - viper.Set("CurrentContentLanguage", helpers.NewLanguage("en")) + viper.SetDefault("defaultContentLanguage", "en") + viper.Set("currentContentLanguage", helpers.NewLanguage("en")) // Test without and with placeholders for _, enablePlaceholders := range []bool{false, true} { - viper.Set("EnableMissingTranslationPlaceholders", enablePlaceholders) + viper.Set("enableMissingTranslationPlaceholders", enablePlaceholders) for _, test := range i18nTests { if enablePlaceholders { diff --git a/tpl/template_resources.go b/tpl/template_resources.go index eb470b3db..507df307e 100644 --- a/tpl/template_resources.go +++ b/tpl/template_resources.go @@ -65,7 +65,7 @@ func (l *remoteLock) URLUnlock(url string) { // getCacheFileID returns the cache ID for a 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 @@ -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. 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 { return c, nil } @@ -128,7 +128,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) { defer func() { remoteURLLock.URLUnlock(url) }() // 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 { return c, nil } @@ -146,7 +146,7 @@ func resGetRemote(url string, fs afero.Fs, hc *http.Client) ([]byte, error) { if err != nil { return nil, err } - err = resWriteCache(url, c, fs, viper.GetBool("IgnoreCache")) + err = resWriteCache(url, c, fs, viper.GetBool("ignoreCache")) if err != nil { 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 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 { return nil, err } diff --git a/tpl/template_resources_test.go b/tpl/template_resources_test.go index 909edc5d5..4f13cc7df 100644 --- a/tpl/template_resources_test.go +++ b/tpl/template_resources_test.go @@ -213,12 +213,12 @@ type wd struct { } func testRetryWhenDone() wd { - cd := viper.GetString("CacheDir") - viper.Set("CacheDir", helpers.GetTempDir("", hugofs.Source())) + cd := viper.GetString("cacheDir") + viper.Set("cacheDir", helpers.GetTempDir("", hugofs.Source())) var tmpSleep time.Duration tmpSleep, resSleep = resSleep, time.Millisecond return wd{func() { - viper.Set("CacheDir", cd) + viper.Set("cacheDir", cd) resSleep = tmpSleep }} } |