Skip to content

Commit

Permalink
Make hugo server -t work again
Browse files Browse the repository at this point in the history
This commit solves an issue where hugo would ignore the cli -t flag
and only use a theme defined in config.toml.

Also allow -t flag to accept a string slice.

Closes gohugoio#5569
Closes gohugoio#5061
Related gohugoio#4868
  • Loading branch information
tryzniak authored and nguyenvanduocit committed Jan 18, 2019
1 parent da21ccc commit 6bc8fef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func (cc *hugoBuilderCommon) handleFlags(cmd *cobra.Command) {
cmd.Flags().StringP("cacheDir", "", "", "filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache/")
cmd.Flags().BoolP("ignoreCache", "", false, "ignores the cache directory")
cmd.Flags().StringP("destination", "d", "", "filesystem path to write files to")
cmd.Flags().StringP("theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
cmd.Flags().StringSliceP("theme", "t", []string{}, "themes to use (located in /themes/THEMENAME/)")
cmd.Flags().StringP("themesDir", "", "", "filesystem path to themes directory")
cmd.Flags().StringVarP(&cc.baseURL, "baseURL", "b", "", "hostname (and path) to the root, e.g. http://spf13.com/")
cmd.Flags().Bool("enableGitInfo", false, "add Git revision, date and author info to the pages")
Expand Down
2 changes: 1 addition & 1 deletion commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestCommandsPersistentFlags(t *testing.T) {
assert.Equal("/tmp/mydestination", cfg.GetString("publishDir"))
assert.Equal("mycontent", cfg.GetString("contentDir"))
assert.Equal("mylayouts", cfg.GetString("layoutDir"))
assert.Equal("mytheme", cfg.GetString("theme"))
assert.Equal([]string{"mytheme"}, cfg.GetStringSlice("theme"))
assert.Equal("mythemes", cfg.GetString("themesDir"))
assert.Equal("https://example.com/b/", cfg.GetString("baseURL"))

Expand Down
2 changes: 1 addition & 1 deletion hugolib/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) {
PaginatePath: cfg.GetString("paginatePath"),
}

if cfg.IsSet("allThemes") {
if !cfg.IsSet("theme") && cfg.IsSet("allThemes") {
p.AllThemes = cfg.Get("allThemes").([]ThemeConfig)
} else {
p.AllThemes, err = collectThemeNames(p)
Expand Down

0 comments on commit 6bc8fef

Please sign in to comment.