From 197aacb6472732126312c22b5bde730ef34258a6 Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Wed, 2 Oct 2013 20:00:21 -0400 Subject: [PATCH] Add support for Relative Permalinks --- docs/content/layout/{index.md => indexes.md} | 0 docs/layouts/index.html | 54 -------------------- hugolib/page.go | 13 +++++ hugolib/site.go | 2 +- 4 files changed, 14 insertions(+), 55 deletions(-) rename docs/content/layout/{index.md => indexes.md} (100%) delete mode 100644 docs/layouts/index.html diff --git a/docs/content/layout/index.md b/docs/content/layout/indexes.md similarity index 100% rename from docs/content/layout/index.md rename to docs/content/layout/indexes.md diff --git a/docs/layouts/index.html b/docs/layouts/index.html deleted file mode 100644 index b6646e751..000000000 --- a/docs/layouts/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - Hugo Static Site Generator written in Go lang - - - {{ template "chrome/includes.html" . }} - - - -
-
-
- {{ template "chrome/menu.html" . }} -
-
- -
-

Hugo

-

A Fast and Flexible Static Site Generator built with love by spf13 - and friends in Go

-

- Get Started -

-
-
-
-

Fast -
-

-

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.
- It's so fast that it will render the site in - less time than it takes to switch to your browser and reload.

-
-
-

Flexible

-

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.

-
-
-

Fun

-

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.

-
-
-{{ template "chrome/footer.html" }} diff --git a/hugolib/page.go b/hugolib/page.go index f35b1a5e0..44f109214 100644 --- 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 index 3f2f565a4..782bafbb7 100644 --- 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)