commit 197aacb6472732126312c22b5bde730ef34258a6
parent 06da609138475de317e7e5fbf3a0a8c3af3c64e4
Author: Noah Campbell <noahcampbell@gmail.com>
Date: Wed, 2 Oct 2013 20:00:21 -0400
Add support for Relative Permalinks
Diffstat:
4 files changed, 14 insertions(+), 55 deletions(-)
diff --git a/docs/content/layout/index.md b/docs/content/layout/indexes.md
diff --git a/docs/layouts/index.html b/docs/layouts/index.html
@@ -1,54 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <title>Hugo Static Site Generator written in Go lang</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
- {{ template "chrome/includes.html" . }}
- </head>
- <body>
- <div class="navbar"></div>
- <div class="container-fluid">
- <div class="row-fluid">
- <div class="span3">
- {{ template "chrome/menu.html" . }}
- </div>
- <div class="span9">
-
- <div class="hero-unit" style="background-color: #222; color: #ccc;">
- <h1>Hugo</h1>
- <p>A Fast and Flexible Static Site Generator built with love by <a href="http://spf13.com">spf13</a>
- and <a href="http://github.com/spf13/hugo/graphs/contributors">friends</a> in Go</p>
- <p>
- <a class="btn btn-large btn-success" href="/doc/installing">Get Started</a>
- </p>
- </div>
- <div class="row-fluid">
- <div class="span4">
- <h2>Fast
- <br>
- </h2>
- <p>Written in GoLang for speed, Hugo is significantly faster than most
- other static site generators.
- A typical website of moderate size can be
- rendered in a fraction of a second. A good rule of thumb is that Hugo
- takes around 1 millisecond for each piece of content.<br>
- It's so fast that it will render the site in
- less time than it takes to switch to your browser and reload.</p>
- </div>
- <div class="span4">
- <h2>Flexible</h2>
- <p>Hugo is made to be very flexible. Define your own content types. Define
- your own indexes. Build your own templates, shortcodes and more.
- It is written to work well with any
- kind of website including blogs, tumbles and docs.</p>
- </div>
- <div class="span4">
- <h2>Fun</h2>
- <p>Hugo runs everywhere. Sites generated with Hugo work on every web
- server without any special configuration. Hugo
- removes all the cruft of building a site allowing you to
- focus on writing great content.</p>
- </div>
- </div>
-{{ template "chrome/footer.html" }}
diff --git a/hugolib/page.go b/hugolib/page.go
@@ -253,6 +253,19 @@ func (p *Page) Permalink() (string, error) {
return link.String(), nil
}
+func (p *Page) RelPermalink() (string, error) {
+ link, err := p.permalink()
+ if err != nil {
+ return "", err
+ }
+
+ link.Scheme = ""
+ link.Host = ""
+ link.User = nil
+ link.Opaque = ""
+ return link.String(), nil
+}
+
func (page *Page) handleTomlMetaData(datum []byte) (interface{}, error) {
m := map[string]interface{}{}
datum = removeTomlIdentifier(datum)
diff --git a/hugolib/site.go b/hugolib/site.go
@@ -551,7 +551,7 @@ func (s *Site) render(d interface{}, out string, layouts ...string) (err error)
section := ""
page, ok := d.(*Page)
if ok {
- section, _ = page.Permalink()
+ section, _ = page.RelPermalink()
}
fmt.Println("Section is:", section)