aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/site_render.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-08-05 11:13:49 +0200
committerBjørn Erik Pedersen <[email protected]>2018-08-06 19:58:41 +0200
commit789ef8c639e4621abd36da530bcb5942ac9297da (patch)
treef225fc3663affc49805f1d309b77b096d40fc8f6 /hugolib/site_render.go
parent71931b30b1813b146aaa60f5cdab16c0f9ebebdb (diff)
downloadhugo-789ef8c639e4621abd36da530bcb5942ac9297da.tar.gz
hugo-789ef8c639e4621abd36da530bcb5942ac9297da.zip
Add support for minification of final output
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar. This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON. To enable, run Hugo with the `--minify` flag: ```bash hugo --minify ``` This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain. Fixes #1251
Diffstat (limited to 'hugolib/site_render.go')
-rw-r--r--hugolib/site_render.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/hugolib/site_render.go b/hugolib/site_render.go
index 2da4064b4..a0d6506e2 100644
--- a/hugolib/site_render.go
+++ b/hugolib/site_render.go
@@ -195,7 +195,7 @@ func (s *Site) renderPaginator(p *PageOutput) error {
// TODO(bep) do better
link := newOutputFormat(p.Page, p.outputFormat).Permalink()
- if err := s.writeDestAlias(target, link, nil); err != nil {
+ if err := s.writeDestAlias(target, link, p.outputFormat, nil); err != nil {
return err
}
@@ -417,7 +417,7 @@ func (s *Site) renderAliases() error {
a = path.Join(lang, a)
}
- if err := s.writeDestAlias(a, plink, p); err != nil {
+ if err := s.writeDestAlias(a, plink, f, p); err != nil {
return err
}
}
@@ -425,18 +425,21 @@ func (s *Site) renderAliases() error {
}
if s.owner.multilingual.enabled() && !s.owner.IsMultihost() {
- mainLang := s.owner.multilingual.DefaultLang
- if s.Info.defaultContentLanguageInSubdir {
- mainLangURL := s.PathSpec.AbsURL(mainLang.Lang, false)
- s.Log.DEBUG.Printf("Write redirect to main language %s: %s", mainLang, mainLangURL)
- if err := s.publishDestAlias(true, "/", mainLangURL, nil); err != nil {
- return err
- }
- } else {
- mainLangURL := s.PathSpec.AbsURL("", false)
- s.Log.DEBUG.Printf("Write redirect to main language %s: %s", mainLang, mainLangURL)
- if err := s.publishDestAlias(true, mainLang.Lang, mainLangURL, nil); err != nil {
- return err
+ html, found := s.outputFormatsConfig.GetByName("HTML")
+ if found {
+ mainLang := s.owner.multilingual.DefaultLang
+ if s.Info.defaultContentLanguageInSubdir {
+ mainLangURL := s.PathSpec.AbsURL(mainLang.Lang, false)
+ s.Log.DEBUG.Printf("Write redirect to main language %s: %s", mainLang, mainLangURL)
+ if err := s.publishDestAlias(true, "/", mainLangURL, html, nil); err != nil {
+ return err
+ }
+ } else {
+ mainLangURL := s.PathSpec.AbsURL("", false)
+ s.Log.DEBUG.Printf("Write redirect to main language %s: %s", mainLang, mainLangURL)
+ if err := s.publishDestAlias(true, mainLang.Lang, mainLangURL, html, nil); err != nil {
+ return err
+ }
}
}
}