Skip to content

Commit

Permalink
hugolib: Only do link transforms etc. on HTML type of pages
Browse files Browse the repository at this point in the history
See #2828
  • Loading branch information
bep committed Apr 7, 2017
1 parent 3c405f5 commit 5714531
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions hugolib/site.go
Expand Up @@ -1893,18 +1893,22 @@ func (s *Site) renderAndWritePage(name string, dest string, p *PageOutput, layou

transformLinks := transform.NewEmptyTransforms()

if s.Info.relativeURLs || s.Info.canonifyURLs {
transformLinks = append(transformLinks, transform.AbsURL)
}
isHTML := p.outputFormat.IsHTML

if s.running() && s.Cfg.GetBool("watch") && !s.Cfg.GetBool("disableLiveReload") {
transformLinks = append(transformLinks, transform.LiveReloadInject(s.Cfg.GetInt("port")))
}
if isHTML {
if s.Info.relativeURLs || s.Info.canonifyURLs {
transformLinks = append(transformLinks, transform.AbsURL)
}

// For performance reasons we only inject the Hugo generator tag on the home page.
if p.IsHome() {
if !s.Cfg.GetBool("disableHugoGeneratorInject") {
transformLinks = append(transformLinks, transform.HugoGeneratorInject)
if s.running() && s.Cfg.GetBool("watch") && !s.Cfg.GetBool("disableLiveReload") {
transformLinks = append(transformLinks, transform.LiveReloadInject(s.Cfg.GetInt("port")))
}

// For performance reasons we only inject the Hugo generator tag on the home page.
if p.IsHome() {
if !s.Cfg.GetBool("disableHugoGeneratorInject") {
transformLinks = append(transformLinks, transform.HugoGeneratorInject)
}
}
}

Expand Down

0 comments on commit 5714531

Please sign in to comment.