site.timer.Step("render and write lists")
site.ProcessShortcodes()
site.timer.Step("render shortcodes")
+ site.AbsUrlify()
+ site.timer.Step("absolute URLify")
site.RenderPages()
site.timer.Step("render pages")
site.RenderHomePage()
}
}
+func (s *Site) AbsUrlify() {
+ for i, _ := range s.Pages {
+ content := string(s.Pages[i].Content)
+ content = strings.Replace(content, " src=\"/", " src=\""+s.c.BaseUrl+"/", -1)
+ content = strings.Replace(content, " src='/", " src='"+s.c.BaseUrl+"/", -1)
+ content = strings.Replace(content, " href='/", " href='"+s.c.BaseUrl+"/", -1)
+ content = strings.Replace(content, " href=\"/", " href=\""+s.c.BaseUrl+"/", -1)
+ s.Pages[i].Content = template.HTML(content)
+ }
+}
+
func (s *Site) CreatePages() {
for _, fileName := range s.Files {
page := NewPage(fileName)
if *baseUrl != "" {
config.BaseUrl = *baseUrl
- }
+ } else if *server {
+ config.BaseUrl = "http://localhost:" + *port
+ }
if *version {
fmt.Println("Hugo Static Site Generator v0.8")