shithub: hugo

Download patch

ref: dcad066025ee8bdb3d0f858b9ea6824fca49cfae
parent: 0bb3b49c00536e7dc89773fdc8e985f78d19715d
author: Alexandre Bourget <[email protected]>
date: Tue Dec 29 19:47:59 EST 2015

Small refactor: don't call `p.Permalink()` for all aliases, call it only
once and only if necessary.

--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -1060,11 +1060,16 @@
 // RenderAliases renders shell pages that simply have a redirect in the header
 func (s *Site) RenderAliases() error {
 	for _, p := range s.Pages {
+		if len(p.Aliases) == 0 {
+			continue
+		}
+
+		plink, err := p.Permalink()
+		if err != nil {
+			return err
+		}
+
 		for _, a := range p.Aliases {
-			plink, err := p.Permalink()
-			if err != nil {
-				return err
-			}
 			if err := s.WriteDestAlias(a, plink); err != nil {
 				return err
 			}