diff --git a/commands/hugo.go b/commands/hugo.go index d3e3bea1e81..c15da0d6526 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -89,7 +89,7 @@ func init() { } func InitializeConfig() { - viper.SetConfigName(CfgFile) + viper.SetConfigFile(CfgFile) viper.AddConfigPath(Source) err := viper.ReadInConfig() if err != nil { diff --git a/commands/server.go b/commands/server.go index 89e4c5ba703..0709d263ff8 100644 --- a/commands/server.go +++ b/commands/server.go @@ -36,8 +36,8 @@ var disableLiveReload bool var serverCmd = &cobra.Command{ Use: "server", - Short: "Hugo runs it's own a webserver to render the files", - Long: `Hugo is able to run it's own high performance web server. + Short: "Hugo runs its own webserver to render the files", + Long: `Hugo is able to run its own high performance web server. Hugo will render all the files defined in the source directory and Serve them up.`, //Run: server, diff --git a/commands/version.go b/commands/version.go index 784255a1938..baeae6a3669 100644 --- a/commands/version.go +++ b/commands/version.go @@ -24,6 +24,6 @@ var version = &cobra.Command{ Short: "Print the version number of Hugo", Long: `All software has versions. This is Hugo's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Hugo Static Site Generator v0.11") + fmt.Println("Hugo Static Site Generator v0.11.1") }, } diff --git a/docs/content/community/press.md b/docs/content/community/press.md index 00ee0c09d72..90d33e104f2 100644 --- a/docs/content/community/press.md +++ b/docs/content/community/press.md @@ -16,6 +16,10 @@ Hugo has been featured in the following Blog Posts, Press and Media. | Title | Author | Date | | ------ | ------ | -----: | +| [Hugo: Beyond the Defaults](http://npf.io/2014/08/hugo-beyond-the-defaults/) | Nate Finch | Aug 8 2014 | +| [Hugo Is Friggin' Awesome](http://npf.io/2014/08/hugo-is-awesome/) | Nate Finch | Aug 1 2014 | +| [An Introduction To Hugo, A Go-Based Static Site Generator](http://www.cirrushosting.com/web-hosting-blog/an-introduction-to-hugo/) | Dan Silber | July 1 2014 | +| [Mission Not Accomplished](http://johnsto.co.uk/blog/mission-not-accomplished/) | Dave Johnston | 3 Apr 2014 | | [Hugo - A Static Site Builder in Go](http://deepfriedcode.com/post/hugo/) | Deep Fried Code | 30 Mar 2014 | | [Hugo](http://bra.am/post/hugo/) | bra.am | 23 Mar 2014 | | [Converting Blogger To Markdown](http://trishagee.github.io/project/atom-to-hugo/) | Trisha Gee | 20 Mar 2014 | diff --git a/docs/content/extras/comments.md b/docs/content/extras/comments.md index a0f881c5140..2b8cce7c4ba 100644 --- a/docs/content/extras/comments.md +++ b/docs/content/extras/comments.md @@ -44,6 +44,38 @@ for a given piece of content * **disqus_title** * **disqus_url** + +## Conditional Loading of Disqus Comments + +Users have noticed that enabling disqus comments when running the hugo web server on localhost causes the creation of unwanted discussions on the associated disqus account. In order to prevent this, a slightly tweaked partial template is required. So, rather than using the built-in `"_internal/disqus.html"` template referenced above, create a template in your `partials` folder that looks like this: + +```javascript +<div id="disqus_thread"></div> +<script type="text/javascript"> + +(function() { + // Don't ever inject disqus on localhost--it creates unwanted + // discussions from 'localhost:1313' on your disqus account... + if (window.location.hostname == "localhost") + return; + + var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; + var disqus_shortname = '{{ .Site.Params.disqusShortname }}'; + dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; + (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); +})(); +</script> +<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> +<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> +``` + +Notice that there is a simple if statement that detects when you are running on localhost and skips the initialization of the disqus comment injection. + +Now reference the partial template from your page template: + + {{ template "partials/disqus.html" . }} + + # Alternatives A few alternatives exist to Disqus. diff --git a/docs/content/extras/menus.md b/docs/content/extras/menus.md index 24b24b775fe..59480168e45 100644 --- a/docs/content/extras/menus.md +++ b/docs/content/extras/menus.md @@ -87,7 +87,7 @@ available. ## Adding (non-content) entries to a menu You can also add entries to menus that aren’t attached to a piece of -content. This takes place in the site wide config file. +content. This takes place in the site wide [config file](http://hugo.spf13.com/overview/configuration). Here’s an example (in toml): @@ -101,6 +101,20 @@ Here’s an example (in toml): pre = "<i class='fa fa-road'></i>" weight = -100 +Here’s an example (in yaml): + + --- + menu: + main: + - Name: "about hugo" + Pre: "<i class='fa fa-heart'></i>" + Weight: -110 + Identifier: "about" + - Name: "getting started" + Pre: "<i class='fa fa-road'></i>" + Weight: -100 + --- + ## Nesting All nesting of content is done via the `parent` field. diff --git a/docs/content/extras/permalinks.md b/docs/content/extras/permalinks.md index 54b4c6104a9..4018b37ed98 100644 --- a/docs/content/extras/permalinks.md +++ b/docs/content/extras/permalinks.md @@ -36,3 +36,18 @@ A file named `content/post/sample-entry` which contains a line appearing at `public/2013/11/sample-entry/index.html` and be reachable via the URL <http://yoursite.example.com/2013/11/sample-entry/>. +The following is a list of values that can be used in a permalink definition, +all references to time are dependent on the content's date. + +**:year** the 4 digit year<br/> +**:month** the 2 digit month<br/> +**:monthname** the name of the month<br/> +**:day** the 2 digit day<br/> +**:weekday** the 1 digit day of the week (Sunday = 0)<br/> +**:weekdayname** the name of the day of the week<br/> +**:yearday** the 1-3 digit day of the year<br/> +**:section** the content's section<br/> +**:title** the content's title<br/> +**:slug** the content's slug (or title if no slug)<br/> +**:filename** the content's filename (without extension)<br/> + diff --git a/docs/content/overview/configuration.md b/docs/content/overview/configuration.md index 4942a02b783..4a499ca6310 100644 --- a/docs/content/overview/configuration.md +++ b/docs/content/overview/configuration.md @@ -61,3 +61,8 @@ Here is a yaml configuration file which sets a few more options SidebarRecentLimit: 5 ... +## Notes + +Config changes do not reflect with [Live Reload](http://hugo.spf13.com/extras/livereload) + +Please restart `hugo server --watch` whenever you make a config change. diff --git a/docs/content/overview/introduction.md b/docs/content/overview/introduction.md index bd5ecdd4082..519826a791e 100644 --- a/docs/content/overview/introduction.md +++ b/docs/content/overview/introduction.md @@ -42,7 +42,7 @@ Hugo boasts the following features: * Extremely fast built times (~1ms per page) * Completely cross platform: Runs on Mac OSX, Linux and Windows * Easy [installation](/overview/installing) - * Render changes [on the fly](/overview/usage) with [live reload](#) as you develop + * Render changes [on the fly](/overview/usage) with [live reload](/extras/livereload) as you develop * Complete theme support * Host your site anywhere @@ -51,8 +51,7 @@ Hugo boasts the following features: * Straightforward [organization](/content/organization) * Support for [website sections](/content/sections) * Completely customizable [urls](/extras/urls) - * Support for [categories](/indexes/category) and tags - * Support for configurable [taxonomies](/indexes/overview) to create your own organization + * Support for configurable [taxonomies](/indexes/overview) which includes categories and tags. Create your own custom organization of content * Ability to [sort content](/content/ordering) as you desire * Automatic [table of contents](/extras/toc) generation * Dynamic menu creation diff --git a/docs/content/overview/quickstart.md b/docs/content/overview/quickstart.md index 7f09f3c7ebf..026f0db5dcf 100644 --- a/docs/content/overview/quickstart.md +++ b/docs/content/overview/quickstart.md @@ -98,6 +98,7 @@ your content Press ctrl+c to stop We specified two options here. + * --theme to pick which theme. * --buildDrafts because we want to display our content, both set to draft status diff --git a/docs/content/taxonomies/usage.md b/docs/content/taxonomies/usage.md index 1b16e558082..4db37364df9 100644 --- a/docs/content/taxonomies/usage.md +++ b/docs/content/taxonomies/usage.md @@ -22,7 +22,7 @@ Notice the format is **singular key** : *plural value*. ### config.yaml --- - taxonomies: + Taxonomies: tag: "tags" category: "categories" series: "series" diff --git a/docs/content/templates/content.md b/docs/content/templates/content.md index 3764103f5ba..a472eeed298 100644 --- a/docs/content/templates/content.md +++ b/docs/content/templates/content.md @@ -32,11 +32,11 @@ it will be used instead of `section`. ### Single -* /layouts/`TYPE` or `SECTION`/`LAYOUT`.html -* /layouts/`TYPE` or `SECTION`/single.html +* /layouts/`TYPE`-or-`SECTION`/`LAYOUT`.html +* /layouts/`TYPE`-or-`SECTION`/single.html * /layouts/\_default/single.html -* /themes/`THEME`/layouts/`TYPE` or `SECTION`/`LAYOUT`.html -* /themes/`THEME`/layouts/`TYPE` or `SECTION`/single.html +* /themes/`THEME`/layouts/`TYPE`-or-`SECTION`/`LAYOUT`.html +* /themes/`THEME`/layouts/`TYPE`-or-`SECTION`/single.html * /themes/`THEME`/layouts/\_default/single.html ## Example Single Template File diff --git a/docs/content/templates/go-templates.md b/docs/content/templates/go-templates.md index 03783e16e5e..8ba16b26eae 100644 --- a/docs/content/templates/go-templates.md +++ b/docs/content/templates/go-templates.md @@ -1,6 +1,7 @@ --- aliases: - /layout/go-templates/ +- /layouts/go-templates/ date: 2013-07-01 menu: main: @@ -220,6 +221,13 @@ Could be rewritten as Stuff Here {{ end }} +### Internet Explorer conditional comments using Pipes + +By default Go Templates remove HTML comments from output. This has the unfortunate side effect of removing Internet Explorer conditional comments. As a workaround, use something like this: + + {{ "<!--[if lt IE 9]>" | safeHtml }} + <script src="html5shiv.js"></script> + {{ "<![endif]-->" | safeHtml }} ## Context (aka. the dot) @@ -335,5 +343,5 @@ so, such as in this example: ``` -[go]: <http://golang.org/> -[gohtmltemplate]: <http://golang.org/pkg/html/template/> +[go]: http://golang.org/ +[gohtmltemplate]: http://golang.org/pkg/html/template/ diff --git a/docs/content/templates/overview.md b/docs/content/templates/overview.md index d04db7a9d8d..a90797ac58d 100644 --- a/docs/content/templates/overview.md +++ b/docs/content/templates/overview.md @@ -57,7 +57,7 @@ Different ways of rendering a (single) content type ### [Taxonomy Terms](/templates/terms) A list of the terms used for a specific taxonomy eg. a Tag cloud -## Other Templates (generally unncessary) +## Other Templates (generally unnecessary) ### [RSS](/templates/rss/) Used to render all rss documents diff --git a/docs/content/themes/creation.md b/docs/content/themes/creation.md index 515fed987e9..0df140265c9 100644 --- a/docs/content/themes/creation.md +++ b/docs/content/themes/creation.md @@ -16,7 +16,7 @@ using the `hugo new` command. This command will initialize all of the files and directories a basic theme would need. Hugo themes are written in the go template language. If you are new -to Go, the [go template primer](/templates/primer/) will help you get started. +to Go, the [go template primer](/layout/go-templates/) will help you get started. ## Theme Components diff --git a/docs/content/themes/overview.md b/docs/content/themes/overview.md index 393213e0fba..10ec16c5df1 100644 --- a/docs/content/themes/overview.md +++ b/docs/content/themes/overview.md @@ -18,7 +18,7 @@ site. Hugo themes have been designed to be the perfect balance between simplicity and functionality. Hugo themes are powered by the excellent go template library. If you are new to go templates, see our [primer on -go templates](/layouts/go-templates). +go templates](/templates/go-templates). Hugo themes support all modern features you come to expect. They are structured in such a way to eliminate code duplication. Themes are also diff --git a/docs/content/tutorials/github_pages_blog.md b/docs/content/tutorials/github_pages_blog.md index f01d3c2147f..bd7140cff1f 100644 --- a/docs/content/tutorials/github_pages_blog.md +++ b/docs/content/tutorials/github_pages_blog.md @@ -131,8 +131,9 @@ To get this properly set up we will execute a series of commands at the terminal # Pull down the file we just committed. This helps avoid merge conflicts git subtree pull --prefix=public - # Run hugo. Generated site will be placed in public directory - hugo + # Run hugo. Generated site will be placed in public directory (or omit -t ThemeName if you're not using a theme) + hugo -t ThemeName + # Add everything git add -A @@ -156,15 +157,29 @@ Now, as you add new posts to your blog, you will follow steps that look somethin * Push the `master` branch * Push the public subtree to the remote `gh-pages` branch -The first two items in the previous list are simply a way to conveniently preview your content as you write. This is a dynamic and fairly streamlined process. All the remaining items, however, are the same every time you want to add new content to the website. To make this repetitive process easier, I have adapted a script from the source repository for the [Chimer Arta & Maker Space](https://github.com/chimera/chimeraarts.org) website that is highlighted in the [Hugo Showcase](/showcase). The script lives in a file called `deploy.sh` and has the following contents +The first two items in the previous list are simply a way to conveniently preview your content as you write. This is a dynamic and fairly streamlined process. All the remaining items, however, are the same every time you want to add new content to the website. To make this repetitive process easier, I have adapted a script from the source repository for the [Chimer Arta & Maker Space](https://github.com/chimera/chimeraarts.org) website that is highlighted in the [Hugo Showcase](/showcase). The script lives in a file called `deploy.sh` and has the following contents: + +**Note:** + +The first command `hugo` assumes you are running with all the default settings. + +To use a theme, make sure to specify it with `-t ThemeName` instead (or include the theme in the config file). + + hugo -t ThemeName + +To build all draft posts *(If you only have drafts, no site will be generated)* + + hugo --buildDrafts + +**Deploy.sh:** #!/bin/bash echo -e "\033[0;32mDeploying updates to Github...\033[0m" - # Build the project. + # Build the project. hugo - + # Add changes to git. git add -A diff --git a/docs/layouts/partials/footer.html b/docs/layouts/partials/footer.html index 1dfd82003a5..961638d8cf7 100644 --- a/docs/layouts/partials/footer.html +++ b/docs/layouts/partials/footer.html @@ -19,8 +19,6 @@ <!-- javascripts --> <script src="/js/jquery.js"></script> <script src="/js/bootstrap.min.js"></script> - <script src="/js/jquery.scrollTo.min.js"></script> - <script src="/js/jquery.nicescroll.js" type="text/javascript"></script> <!--custom script for all page--> <script src="/js/highlight.pack.js"></script> <script>hljs.initHighlightingOnLoad();</script> diff --git a/docs/static/css/style.css b/docs/static/css/style.css index f32af063b8a..792d53cf357 100755 --- a/docs/static/css/style.css +++ b/docs/static/css/style.css @@ -354,10 +354,11 @@ table tr th { color: #007AFF;} /*sidebar navigation*/ #sidebar { - width: 180px; + width: 190px; height: 100%; position: fixed; background: #ffffff; + overflow-y: auto; } .nav-collapse.collapse { diff --git a/docs/static/js/scripts.js b/docs/static/js/scripts.js index 65c537bb806..5ecfa332470 100755 --- a/docs/static/js/scripts.js +++ b/docs/static/js/scripts.js @@ -6,14 +6,6 @@ function initializeJS() { //popovers jQuery('.popovers').popover(); - //custom scrollbar - //for html - jQuery("html").niceScroll({styler:"fb",cursorcolor:"#007AFF", cursorwidth: '6', cursorborderradius: '10px', background: '#F7F7F7', cursorborder: '', zindex: '1000'}); - //for sidebar - jQuery("#sidebar").niceScroll({styler:"fb",cursorcolor:"#007AFF", cursorwidth: '3', cursorborderradius: '10px', background: '#F7F7F7', cursorborder: ''}); - // for scroll panel - jQuery(".scroll-panel").niceScroll({styler:"fb",cursorcolor:"#007AFF", cursorwidth: '3', cursorborderradius: '10px', background: '#F7F7F7', cursorborder: ''}); - //sidebar dropdown menu jQuery('#sidebar .sub-menu > a').click(function () { var last = jQuery('.sub-menu.open', jQuery('#sidebar')); diff --git a/hugolib/page.go b/hugolib/page.go index 94c9b928a03..0cbb7802c5e 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -190,11 +190,21 @@ func (page *Page) Layout(l ...string) []string { func layouts(types string, layout string) (layouts []string) { t := strings.Split(types, "/") + + // Add type/layout.html for i := range t { search := t[:len(t)-i] layouts = append(layouts, fmt.Sprintf("%s/%s.html", strings.ToLower(path.Join(search...)), layout)) } - layouts = append(layouts, fmt.Sprintf("%s.html", layout)) + + // Add _default/layout.html + layouts = append(layouts, fmt.Sprintf("_default/%s.html", layout)) + + // Add theme/type/layout.html & theme/_default/layout.html + for _, l := range layouts { + layouts = append(layouts, "theme/"+l) + } + return } @@ -504,12 +514,18 @@ func (p *Page) Render(layout ...string) template.HTML { func (p *Page) ExecuteTemplate(layout string) *bytes.Buffer { l := p.Layout(layout) buffer := new(bytes.Buffer) + worked := false for _, layout := range l { if p.Tmpl.Lookup(layout) != nil { p.Tmpl.ExecuteTemplate(buffer, layout, p) + worked = true break } } + if !worked { + jww.ERROR.Println("Unable to render", layout, ".") + jww.ERROR.Println("Expecting to find a template in either the theme/layouts or /layouts in one of the following relative locations", l) + } return buffer } diff --git a/hugolib/page_test.go b/hugolib/page_test.go index 0ade5c950bb..81a168638ed 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -307,7 +307,7 @@ func TestCreateNewPage(t *testing.T) { checkPageContent(t, p, "<p>Simple Page</p>\n") checkPageSummary(t, p, "Simple Page") checkPageType(t, p, "page") - checkPageLayout(t, p, "page/single.html", "single.html") + checkPageLayout(t, p, "page/single.html", "_default/single.html", "theme/page/single.html", "theme/_default/single.html") checkTruncation(t, p, false, "simple short page") } @@ -322,7 +322,7 @@ func TestPageWithDelimiter(t *testing.T) { checkPageContent(t, p, "<p>Summary Next Line</p>\n\n<p>Some more text</p>\n") checkPageSummary(t, p, "<p>Summary Next Line</p>\n") checkPageType(t, p, "page") - checkPageLayout(t, p, "page/single.html", "single.html") + checkPageLayout(t, p, "page/single.html", "_default/single.html", "theme/page/single.html", "theme/_default/single.html") checkTruncation(t, p, true, "page with summary delimiter") } @@ -337,7 +337,7 @@ func TestPageWithShortCodeInSummary(t *testing.T) { checkPageContent(t, p, "<p>Summary Next Line. {{% img src=“/not/real” %}}.\nMore text here.</p>\n\n<p>Some more text</p>\n") checkPageSummary(t, p, "Summary Next Line. . More text here. Some more text") checkPageType(t, p, "page") - checkPageLayout(t, p, "page/single.html", "single.html") + checkPageLayout(t, p, "page/single.html", "_default/single.html", "theme/page/single.html", "theme/_default/single.html") } func TestTableOfContents(t *testing.T) { @@ -362,7 +362,7 @@ func TestPageWithMoreTag(t *testing.T) { checkPageContent(t, p, "<p>Summary Same Line</p>\n\n<p>Some more text</p>\n") checkPageSummary(t, p, "<p>Summary Same Line</p>\n") checkPageType(t, p, "page") - checkPageLayout(t, p, "page/single.html", "single.html") + checkPageLayout(t, p, "page/single.html", "_default/single.html", "theme/page/single.html", "theme/_default/single.html") } func TestPageWithDate(t *testing.T) { @@ -513,25 +513,25 @@ func TestLayoutOverride(t *testing.T) { path string expectedLayout []string }{ - {SIMPLE_PAGE_NOLAYOUT, path_content_two_dir, L("dub/sub/single.html", "dub/single.html", "single.html")}, - {SIMPLE_PAGE_NOLAYOUT, path_content_one_dir, L("gub/single.html", "single.html")}, - {SIMPLE_PAGE_NOLAYOUT, path_content_no_dir, L("page/single.html", "single.html")}, - {SIMPLE_PAGE_NOLAYOUT, path_one_directory, L("fub/single.html", "single.html")}, - {SIMPLE_PAGE_NOLAYOUT, path_no_directory, L("page/single.html", "single.html")}, - {SIMPLE_PAGE_LAYOUT_FOOBAR, path_content_two_dir, L("dub/sub/foobar.html", "dub/foobar.html", "foobar.html")}, - {SIMPLE_PAGE_LAYOUT_FOOBAR, path_content_one_dir, L("gub/foobar.html", "foobar.html")}, - {SIMPLE_PAGE_LAYOUT_FOOBAR, path_one_directory, L("fub/foobar.html", "foobar.html")}, - {SIMPLE_PAGE_LAYOUT_FOOBAR, path_no_directory, L("page/foobar.html", "foobar.html")}, - {SIMPLE_PAGE_TYPE_FOOBAR, path_content_two_dir, L("foobar/single.html", "single.html")}, - {SIMPLE_PAGE_TYPE_FOOBAR, path_content_one_dir, L("foobar/single.html", "single.html")}, - {SIMPLE_PAGE_TYPE_FOOBAR, path_content_no_dir, L("foobar/single.html", "single.html")}, - {SIMPLE_PAGE_TYPE_FOOBAR, path_one_directory, L("foobar/single.html", "single.html")}, - {SIMPLE_PAGE_TYPE_FOOBAR, path_no_directory, L("foobar/single.html", "single.html")}, - {SIMPLE_PAGE_TYPE_LAYOUT, path_content_two_dir, L("barfoo/buzfoo.html", "buzfoo.html")}, - {SIMPLE_PAGE_TYPE_LAYOUT, path_content_one_dir, L("barfoo/buzfoo.html", "buzfoo.html")}, - {SIMPLE_PAGE_TYPE_LAYOUT, path_content_no_dir, L("barfoo/buzfoo.html", "buzfoo.html")}, - {SIMPLE_PAGE_TYPE_LAYOUT, path_one_directory, L("barfoo/buzfoo.html", "buzfoo.html")}, - {SIMPLE_PAGE_TYPE_LAYOUT, path_no_directory, L("barfoo/buzfoo.html", "buzfoo.html")}, + {SIMPLE_PAGE_NOLAYOUT, path_content_two_dir, L("dub/sub/single.html", "dub/single.html", "_default/single.html")}, + {SIMPLE_PAGE_NOLAYOUT, path_content_one_dir, L("gub/single.html", "_default/single.html")}, + {SIMPLE_PAGE_NOLAYOUT, path_content_no_dir, L("page/single.html", "_default/single.html")}, + {SIMPLE_PAGE_NOLAYOUT, path_one_directory, L("fub/single.html", "_default/single.html")}, + {SIMPLE_PAGE_NOLAYOUT, path_no_directory, L("page/single.html", "_default/single.html")}, + {SIMPLE_PAGE_LAYOUT_FOOBAR, path_content_two_dir, L("dub/sub/foobar.html", "dub/foobar.html", "_default/foobar.html")}, + {SIMPLE_PAGE_LAYOUT_FOOBAR, path_content_one_dir, L("gub/foobar.html", "_default/foobar.html")}, + {SIMPLE_PAGE_LAYOUT_FOOBAR, path_one_directory, L("fub/foobar.html", "_default/foobar.html")}, + {SIMPLE_PAGE_LAYOUT_FOOBAR, path_no_directory, L("page/foobar.html", "_default/foobar.html")}, + {SIMPLE_PAGE_TYPE_FOOBAR, path_content_two_dir, L("foobar/single.html", "_default/single.html")}, + {SIMPLE_PAGE_TYPE_FOOBAR, path_content_one_dir, L("foobar/single.html", "_default/single.html")}, + {SIMPLE_PAGE_TYPE_FOOBAR, path_content_no_dir, L("foobar/single.html", "_default/single.html")}, + {SIMPLE_PAGE_TYPE_FOOBAR, path_one_directory, L("foobar/single.html", "_default/single.html")}, + {SIMPLE_PAGE_TYPE_FOOBAR, path_no_directory, L("foobar/single.html", "_default/single.html")}, + {SIMPLE_PAGE_TYPE_LAYOUT, path_content_two_dir, L("barfoo/buzfoo.html", "_default/buzfoo.html")}, + {SIMPLE_PAGE_TYPE_LAYOUT, path_content_one_dir, L("barfoo/buzfoo.html", "_default/buzfoo.html")}, + {SIMPLE_PAGE_TYPE_LAYOUT, path_content_no_dir, L("barfoo/buzfoo.html", "_default/buzfoo.html")}, + {SIMPLE_PAGE_TYPE_LAYOUT, path_one_directory, L("barfoo/buzfoo.html", "_default/buzfoo.html")}, + {SIMPLE_PAGE_TYPE_LAYOUT, path_no_directory, L("barfoo/buzfoo.html", "_default/buzfoo.html")}, } for _, test := range tests { p, _ := NewPage(test.path) @@ -539,6 +539,10 @@ func TestLayoutOverride(t *testing.T) { if err != nil { t.Fatalf("Unable to parse content:\n%s\n", test.content) } + + for _, y := range test.expectedLayout { + test.expectedLayout = append(test.expectedLayout, "theme/"+y) + } if !listEqual(p.Layout(), test.expectedLayout) { t.Errorf("Layout mismatch. Expected: %s, got: %s", test.expectedLayout, p.Layout()) } diff --git a/hugolib/path_seperators_test.go b/hugolib/path_seperators_test.go index 816769d9758..187c155b5e4 100644 --- a/hugolib/path_seperators_test.go +++ b/hugolib/path_seperators_test.go @@ -28,10 +28,10 @@ func TestNewPageWithFilePath(t *testing.T) { section string layout []string }{ - {path.Join("sub", "foobar.html"), "sub", L("sub/single.html", "single.html")}, - {path.Join("content", "foobar.html"), "", L("page/single.html", "single.html")}, - {path.Join("content", "sub", "foobar.html"), "sub", L("sub/single.html", "single.html")}, - {path.Join("content", "dub", "sub", "foobar.html"), "dub/sub", L("dub/sub/single.html", "dub/single.html", "single.html")}, + {path.Join("sub", "foobar.html"), "sub", L("sub/single.html", "_default/single.html")}, + {path.Join("content", "foobar.html"), "", L("page/single.html", "_default/single.html")}, + {path.Join("content", "sub", "foobar.html"), "sub", L("sub/single.html", "_default/single.html")}, + {path.Join("content", "dub", "sub", "foobar.html"), "dub/sub", L("dub/sub/single.html", "dub/single.html", "_default/single.html")}, } for _, el := range toCheck { @@ -44,6 +44,10 @@ func TestNewPageWithFilePath(t *testing.T) { t.Errorf("Section not set to %s for page %s. Got: %s", el.section, el.input, p.Section) } + for _, y := range el.layout { + el.layout = append(el.layout, "theme/"+y) + } + if !listEqual(p.Layout(), el.layout) { t.Errorf("Layout incorrect. Expected: '%s', Got: '%s'", el.layout, p.Layout()) } diff --git a/parser/frontmatter.go b/parser/frontmatter.go index d3c3f034762..68e4456d2a5 100644 --- a/parser/frontmatter.go +++ b/parser/frontmatter.go @@ -20,7 +20,7 @@ import ( "strings" "github.com/BurntSushi/toml" - "launchpad.net/goyaml" + "gopkg.in/yaml.v1" ) type FrontmatterType struct { @@ -38,7 +38,7 @@ func InterfaceToConfig(in interface{}, mark rune) ([]byte, error) { switch mark { case rune(YAML_LEAD[0]): - by, err := goyaml.Marshal(in) + by, err := yaml.Marshal(in) if err != nil { return nil, err } @@ -83,7 +83,7 @@ func InterfaceToFrontMatter(in interface{}, mark rune) ([]byte, error) { if err != nil { return nil, err } - by, err := goyaml.Marshal(in) + by, err := yaml.Marshal(in) if err != nil { return nil, err } @@ -178,7 +178,7 @@ func removeTomlIdentifier(datum []byte) []byte { func HandleYamlMetaData(datum []byte) (interface{}, error) { m := map[string]interface{}{} - if err := goyaml.Unmarshal(datum, &m); err != nil { + if err := yaml.Unmarshal(datum, &m); err != nil { return m, err } return m, nil