diff --git a/hugolib/helpers.go b/hugolib/helpers.go index 4ebeea998..ad3c20277 100644 --- a/hugolib/helpers.go +++ b/hugolib/helpers.go @@ -22,6 +22,7 @@ import ( "regexp" "strconv" "strings" + "html/template" "time" ) @@ -147,6 +148,13 @@ func Urlize(url string) string { return Sanitize(strings.ToLower(strings.Replace(strings.TrimSpace(url), " ", "-", -1))) } +func AbsUrl(url string, base string) template.HTML { + if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") { + return template.HTML(url) + } + return template.HTML(MakePermalink(base, url)) +} + func Gt(a interface{}, b interface{}) bool { var left, right int64 av := reflect.ValueOf(a)