commit 9e52477d94f56364fbdfa1a70692429eb05d7242
parent c7535b9c259804bba3c9a6114f42e4ffb3373eec
Author: bogem <albertnigma@gmail.com>
Date: Mon, 20 Feb 2017 13:52:06 +0500
hugolib: Add relativeURLs and canonifyURLs to Site
Diffstat:
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/hugolib/page.go b/hugolib/page.go
@@ -940,8 +940,7 @@ func (p *Page) RelPermalink() string {
p.relPermalinkInit.Do(func() {
link := p.getPermalink()
- if p.s.Info.canonifyURLs {
- // replacements for relpermalink with baseURL on the form http://myhost.com/sub/ will fail later on
+ if p.s.Info.canonifyURLs { // replacements for relpermalink with baseURL on the form http://myhost.com/sub/ will fail later on
// have to return the URL relative from baseURL
relpath, err := helpers.GetRelativePath(link.String(), string(p.Site.BaseURL))
if err != nil {
diff --git a/hugolib/site.go b/hugolib/site.go
@@ -249,6 +249,7 @@ type SiteInfo struct {
Params map[string]interface{}
BuildDrafts bool
canonifyURLs bool
+ relativeURLs bool
preserveTaxonomyNames bool
Data *map[string]interface{}
@@ -977,6 +978,7 @@ func (s *Site) initializeSiteInfo() {
GoogleAnalytics: lang.GetString("googleAnalytics"),
BuildDrafts: s.Cfg.GetBool("buildDrafts"),
canonifyURLs: s.Cfg.GetBool("canonifyURLs"),
+ relativeURLs: s.Cfg.GetBool("relativeURLs"),
preserveTaxonomyNames: lang.GetBool("preserveTaxonomyNames"),
PageCollections: s.PageCollections,
Files: &s.Files,
@@ -1744,7 +1746,7 @@ func (s *Site) renderAndWriteXML(name string, dest string, d interface{}, layout
defer bp.PutBuffer(outBuffer)
var path []byte
- if s.Cfg.GetBool("relativeURLs") {
+ if s.Info.relativeURLs {
path = []byte(helpers.GetDottedRelativePath(dest))
} else {
s := s.Cfg.GetString("baseURL")
@@ -1784,9 +1786,8 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
}
transformLinks := transform.NewEmptyTransforms()
- relativeURLs := s.Cfg.GetBool("relativeURLs")
- if relativeURLs || s.Info.canonifyURLs {
+ if s.Info.relativeURLs || s.Info.canonifyURLs {
transformLinks = append(transformLinks, transform.AbsURL)
}
@@ -1803,7 +1804,7 @@ func (s *Site) renderAndWritePage(name string, dest string, d interface{}, layou
var path []byte
- if relativeURLs {
+ if s.Info.relativeURLs {
translated, err := pageTarget.(target.OptionalTranslator).TranslateRelative(dest)
if err != nil {
return err
@@ -1982,7 +1983,7 @@ func (s *Site) writeDestAlias(path, permalink string, p *Page) (err error) {
}
func (s *Site) publishDestAlias(aliasPublisher target.AliasPublisher, path, permalink string, p *Page) (err error) {
- if s.Cfg.GetBool("relativeURLs") {
+ if s.Info.relativeURLs {
// convert `permalink` into URI relative to location of `path`
baseURL := helpers.SanitizeURLKeepTrailingSlash(s.Cfg.GetString("baseURL"))
if strings.HasPrefix(permalink, baseURL) {