Skip to content

Commit

Permalink
hugolib: Add disableAliases
Browse files Browse the repository at this point in the history
Note that even with this setting enabled, the aliases themselves are preserved on the pages.

The big motivation for this change is to be able to use the alias definitions to generate `.htaccess` or Netlify's `_redirect` files with server-side redirects.

Fixes #3613
  • Loading branch information
bep committed Jun 20, 2017
1 parent 3183b9a commit 516e6c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions hugolib/config.go
Expand Up @@ -131,4 +131,5 @@ func loadDefaultSettingsFor(v *viper.Viper) {
v.SetDefault("enableMissingTranslationPlaceholders", false) v.SetDefault("enableMissingTranslationPlaceholders", false)
v.SetDefault("enableGitInfo", false) v.SetDefault("enableGitInfo", false)
v.SetDefault("ignoreFiles", make([]string, 0)) v.SetDefault("ignoreFiles", make([]string, 0))
v.SetDefault("disableAliases", false)
} }
19 changes: 12 additions & 7 deletions hugolib/site.go
Expand Up @@ -987,14 +987,19 @@ func (s *Site) render(outFormatIdx int) (err error) {
} }
s.timerStep("prepare pages") s.timerStep("prepare pages")


// Aliases must be rendered before pages. // Note that even if disableAliases is set, the aliases themselves are
// Some sites, Hugo docs included, have faulty alias definitions that point // preserved on page. The motivation with this is to be able to generate
// to itself or another real page. These will be overwritten in the next // 301 redirects in a .htacess file and similar using a custom output format.
// step. if !s.Cfg.GetBool("disableAliases") {
if err = s.renderAliases(); err != nil { // Aliases must be rendered before pages.
return // Some sites, Hugo docs included, have faulty alias definitions that point
// to itself or another real page. These will be overwritten in the next
// step.
if err = s.renderAliases(); err != nil {
return
}
s.timerStep("render and write aliases")
} }
s.timerStep("render and write aliases")


} }


Expand Down

0 comments on commit 516e6c6

Please sign in to comment.