Expose canonifyURLs as a command flag - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 63d9859c09692fb8fbe6e43c441c08559aea9472
DIR parent 002227e05ef05ac0f98747dd37fd4053d88d12e6
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sat, 10 Oct 2015 10:50:55 +0200
Expose canonifyURLs as a command flag
Needed by the theme site.
Diffstat:
M commands/hugo.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
DIR diff --git a/commands/hugo.go b/commands/hugo.go
@@ -60,7 +60,7 @@ Complete documentation is available at http://gohugo.io/.`,
var hugoCmdV *cobra.Command
//Flags that are to be added to commands.
-var BuildWatch, IgnoreCache, Draft, Future, UglyURLs, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, PreserveTaxonomyNames, NoTimes bool
+var BuildWatch, IgnoreCache, Draft, Future, UglyURLs, CanonifyURLs, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles, PreserveTaxonomyNames, NoTimes bool
var Source, CacheDir, Destination, Theme, BaseURL, CfgFile, LogFile, Editor string
//Execute adds all child commands to the root command HugoCmd and sets flags appropriately.
@@ -102,6 +102,7 @@ func init() {
HugoCmd.PersistentFlags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
HugoCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
HugoCmd.PersistentFlags().BoolVar(&UglyURLs, "uglyURLs", false, "if true, use /filename.html instead of /filename/")
+ HugoCmd.PersistentFlags().BoolVar(&CanonifyURLs, "canonifyURLs", false, "if true, all relative URLs will be canonicalized using baseURL")
HugoCmd.PersistentFlags().StringVarP(&BaseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
HugoCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)")
HugoCmd.PersistentFlags().StringVar(&Editor, "editor", "", "edit new content with this editor, if provided")
@@ -201,6 +202,10 @@ func InitializeConfig() {
viper.Set("UglyURLs", UglyURLs)
}
+ if hugoCmdV.PersistentFlags().Lookup("canonifyURLs").Changed {
+ viper.Set("CanonifyURLs", CanonifyURLs)
+ }
+
if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed {
viper.Set("DisableRSS", DisableRSS)
}