Compare commits

...

623 Commits

Author SHA1 Message Date
spf13 1363128962 Bumping Version 2014-09-01 10:05:05 -04:00
spf13 b4d3195f65 Adding V0.12 release notes 2014-09-01 10:00:45 -04:00
spf13 f36ed446cc Adding a bunch of new quotes to the front page and switching to Owl Carousel 2014-09-01 10:00:06 -04:00
Anthony Fok d202050684 Fix loading of Lato font in style.css for docs
The "@import url()" statement for loading Lato from Google Fonts
was ignored because "@import are not allowed after any valid statement
other than @charset and @import" according to the W3C CSS Validator.

Also remove the line for importing line-icons.css which no longer
exists.
2014-09-01 08:21:42 -04:00
Anthony Fok a6022293af Minor proofreading corrections to Hugo docs 2014-09-01 08:19:40 -04:00
Dato Simó f142458c4b Use typographic quote chars in the carousel quotes section
At big font sizes, quotes really become more beautiful with them.
2014-08-30 23:19:22 -04:00
Dave Johnston 13a317b975 Enable header id blackfriday extension 2014-08-30 14:12:53 -04:00
Anthony Fok c1b9e8d54b quickstart.md: Put long options inside backticks
Also minor adjustment to blank lines.
2014-08-30 01:16:18 -04:00
spf13 242d6b4e6b Adjusting the number of go routines to build the pages in to 4*GOMAXPROCS (from 2) for faster rendering. 2014-08-30 01:15:20 -04:00
Nate Finch 47c91a4ca2 Fix CreatePages
This fixes #450.  There are two problems:

1.) We're creating a new goroutine for every page.
2.) We're calling s.Pages = append(s.Pages, page) inside each goroutine.

1 is a problem if in that if you have a ton of pages, that's a ton of goroutines.  It's not really useful to have more than a few goroutines at a time, and lots can actually make your code much slower, and, evidently, crash.

2 is a problem in that append is not thread safe. Sometimes it returns a new slice with a larger capacity, when the original slice isn't large enough.  This can cause problems if two goroutines do this at the same time.

The solution for 1 is to use a limited number of workers (I chose 2*GOMAXPROCS as a nice guess).
The solution for 2 is to serialize access to s.Pages, which I did by doing it in a single goroutine.
2014-08-30 01:02:35 -04:00
spf13 93addfcbee Adding documentation about 'where' and cleaning up docs around first. 2014-08-30 00:57:38 -04:00
spf13 0ce4ec1edb Added more examples and cleaned up the GroupBy functionality documentation 2014-08-30 00:21:47 -04:00
spf13 7e19fa40e7 Making direction optional (and setting defaults) for GroupBy Pages functionality. 2014-08-29 23:51:29 -04:00
spf13 b15eb889e8 Adding .Reverse() to PagesGroup 2014-08-29 23:50:25 -04:00
spf13 41b28462e8 Switch .Data to .Pages in the PageGroup functionality for increased consistency. 2014-08-29 23:48:24 -04:00
spf13 70dc370c08 Making the term "Term" more consistent with Taxonomy usage. 2014-08-29 23:44:39 -04:00
spf13 01caaeba7a Making the Pages Sorting methods available within a taxonomy term. 2014-08-29 23:43:38 -04:00
spf13 bb02a14b1e Adding a page listing the different methods available to Taxonomies. 2014-08-29 23:42:26 -04:00
spf13 ba8f652acc More taxonomy examples in templates. 2014-08-29 23:41:53 -04:00
spf13 6f9f93f34b Fixing the taxonomy example. Fixed #318. 2014-08-29 23:39:55 -04:00
Jakub Turski d3646aaac0 Be more specific about .Params content
I'm not sure whether this is *always* the case, but it's definitely have been my experience so far. :)
2014-08-28 13:04:00 -04:00
Jakub Turski 7de320920c Shortcodes are content files specific.
This fixes spf13/hugo#440.
2014-08-28 12:59:52 -04:00
Tatsushi Demachi 6f9db4a784 Add document about page grouping functions 2014-08-28 12:56:32 -04:00
spf13 53b7d5b8a1 Inner Shortcodes now treated as markdown. fixed #185 2014-08-28 12:48:31 -04:00
spf13 828401cbe6 More press additions 2014-08-27 11:47:12 -04:00
spf13 4b71eb16e1 Compressed showcase thumbnails further 2014-08-26 14:37:34 -04:00
spf13 954498803d Added ucsb to showcase 2014-08-26 14:37:12 -04:00
spf13 dcda66dfab More Press 2014-08-26 14:36:38 -04:00
spf13 4a91b8c7fd fixed #389 . Added alias for missing page. 2014-08-26 13:16:45 -04:00
spf13 987a82d043 small tweaks to the hover effect 2014-08-26 12:30:28 -04:00
spf13 8a44deac0f Creating a showcase archetype to make for easier showcase additions 2014-08-26 12:27:43 -04:00
spf13 1c1615d794 Adding a bunch of new sites to the showcase 2014-08-26 12:27:25 -04:00
spf13 c9a6b2b93c Adding a bunch of new press to the Press page. 2014-08-26 12:26:29 -04:00
spf13 733bff9035 Prettier link hover state 2014-08-25 15:52:43 -04:00
spf13 1143a8fa49 Bumping Travis to test Go 1.2 & tip (1.3) 2014-08-25 15:18:53 -04:00
spf13 294222ac74 Fixing a broken link in the docs 2014-08-25 14:02:39 -04:00
spf13 4281cbfa34 LiveReloadDisabled works with Watching properly. Fixed #335. 2014-08-25 13:49:53 -04:00
spf13 1b5f59b071 go fmt site.go 2014-08-25 13:13:11 -04:00
spf13 30af267b32 Fix #302. Links now have trailing slashes. 2014-08-25 12:45:47 -04:00
Nate Finch a31edb3388 Support subdir in baseurl.
Mainly this was a change to helpers.MakePermalink, but to get the local server to run correctly,
we needed to redirect the path of the request from /foo to /.  In addition, I added tests for the
server's code for fixing up the base url with different config file & CLI options.
2014-08-25 11:51:51 -04:00
Joel Scoble 4b979b17cc added functionality to check the error message returned from Cobra, if any. for uage message text. If its present, the usage message gets truncated and the resulting message is returned to be used for the rest of the error message. If the resulting error is blank, no error message is printed 2014-08-25 11:50:23 -04:00
Joel Scoble 4c735a7878 preserve alias case while lowercasing taxonomy 2014-08-25 10:16:59 -04:00
Chase Adams 348e123c9f Update 404 to be compiled to .html instead of directory 2014-08-25 09:38:08 -04:00
Tatsushi Demachi 50a8c50726 Add page grouping functions 2014-08-25 09:18:52 -04:00
Chase Adams 867683e473 Add link for learning more about static directory 2014-08-20 14:23:17 -04:00
Joel Scoble c750a95e22 support for futre/draft summary info output 2014-08-20 14:21:15 -04:00
spf13 946ad9c2c3 Making the links stand out more 2014-08-20 14:19:15 -04:00
spf13 f5157566ef Cleaning up a ton of CSS.. Removing unused selectors. Eliminated over 80% of CSS. Upgrading jQuery & FA 2014-08-20 14:10:36 -04:00
spf13 34a93fa1f3 Fixing the docs sidebar interactions 2014-08-20 13:13:51 -04:00
spf13 04d412ed16 Fixed showcase image paths 2014-08-20 11:17:38 -04:00
Joel Scoble cece27fa2e fix issue 411, /path/to/site/archetypes : is a directory error 2014-08-19 22:30:21 -04:00
spf13 e31d460909 Bringing back the showcase 2014-08-19 21:47:38 -04:00
spf13 b047e2f880 Removing redundant bootstrap 2014-08-19 21:46:27 -04:00
spf13 864f91d90e Changing the docs template partials to be able to be used to render a section 2014-08-19 21:28:37 -04:00
spf13 aae1ff3c92 Adding IsNode & IsPage functions to Page & Node 2014-08-19 21:27:13 -04:00
Joel Scoble b10dea2955 added evaluation for toml for metadataformat date handling 2014-08-18 12:01:50 -04:00
Franklin Wise 27c0ec3163 Added a note after the script adding potential issues per @franklinwise's feedback 2014-08-18 11:58:49 -04:00
Franklin Wise 5ae2832713 errors not propagating 2014-08-18 11:43:55 -04:00
Andrew Gerrand 634d7b2638 switch to new location of goyaml 2014-08-18 11:31:55 -04:00
Tatsushi Demachi 002a5b6756 Add 'where' template function 2014-08-18 11:31:17 -04:00
Rahul Bansal 6e15f652bd Added yaml menu example
Added yaml menu example, matching with existing toml example. Also added link to sitewide config page.
2014-08-18 11:30:00 -04:00
Rahul Bansal 5d8ac54f73 Config changes and Live Reload
I noticed that config file changes do not work with Live Reload feature. This may be "fixed" in future but for now adding a note might avoid confusion.
2014-08-18 11:28:42 -04:00
Roberto Dip 09115a9623 Fix #394 - Docs: add a missing link to the livereload page in the intro 2014-08-18 11:24:53 -04:00
Franklin Wise e9b47da081 hugo builds no site if there are only drafts
if you run:
hugo
and all of your posts are drafts, no site gets build.
2014-08-18 11:21:45 -04:00
spf13 3e9fc47ad2 Adding more press 2014-08-10 00:17:36 -04:00
David Kebler cbb29795c3 Docs-removed bullet and broken link for catagetories. Included category text in bullet for taxonomies 2014-08-09 23:31:28 -04:00
Roberto Dip b3130b52f3 Fix #363 - Docs: make the fixed menu on the left scrollable 2014-08-09 23:21:33 -04:00
Nate Finch 1778f28c87 remove extraneous "Because" 2014-08-06 05:39:58 -04:00
Nate Finch f556cb4414 update docs for permalinks with all fields
List all the fields and what they mean, based on hugolib/permalinks.go
2014-08-06 00:05:40 -04:00
Nate Finch 29c45dd690 make type-or-section more obvious
It took me a long time to realize that /layouts/TYPE or SECTION/LAYOUT.html  was supposed to be a single URL and not two urls (/layouts/TYPE) or (SECTION/LAYOUT.html) ... putting in the hyphens I think makes it much more clear it's all one URL, and only the middle part is an either-or.
2014-08-06 00:05:05 -04:00
Nate Finch 756be987d3 Merge pull request #388 from GraemeCaldwell/patch-2
Update press.md
2014-08-05 13:13:09 -04:00
GraemeCaldwell d8b78c3da2 Update press.md 2014-08-05 17:19:56 +01:00
Nate Finch 2850692a76 Merge pull request #370 from kevinburke/its
it's/its
2014-08-05 11:13:27 -04:00
Kevin Burke 657e4a46e8 it's/its 2014-07-26 23:43:21 -07:00
spf13 bf9595aa24 Fixed #328. Config file set appropriately. 2014-07-01 10:59:58 -04:00
spf13 8d3fa7ef49 Getting rid of bad scrollbar 2014-06-30 23:41:53 -04:00
Billie H. Cleek aa42f4309c allow site to be built with empty content
Build the site even if there isn't anything in the content directory.
2014-06-30 15:28:18 -04:00
Billie H. Cleek 73dd4f38d0 report errors
Modify CheckErr and StopOnErrErr to report the error if there aren't any
other messages.
2014-06-30 15:26:40 -04:00
Nicholas Whittier 78962a14f8 Allows 404 templates from themes/THEME directories. 2014-06-30 15:22:52 -04:00
Nicholas Whittier ac99ceccac Add shortcode template loading from themes directory. 2014-06-30 15:22:18 -04:00
Kristoffer Grönlund 35d04671d3 Add PluralizeListTitles option (default true) to allow disabling use of the inflect package 2014-06-30 15:21:09 -04:00
Gina White 3eb480a62f fix link to template primer 2014-06-30 15:20:03 -04:00
Maarten Everts b76719744d taxonomies -> Taxonomies 2014-06-30 15:19:28 -04:00
Rolando Pereira 836b1800f9 Fix minor typo in file docs/content/templates/overview.md 2014-06-30 15:18:46 -04:00
Gour 0e57e32f54 do not use angle brackets in hyperlink labels 2014-06-30 15:16:30 -04:00
Andrew Jones 5969315c8f switch back to master blackfriday; enable footnotes 2014-06-30 15:14:42 -04:00
Michael Whatcott 406233f052 Included instructions for omitting disqus comments on localhost. 2014-06-30 14:55:42 -04:00
jesper-mortensen 86c3de4be1 Fix #263, document HTML comments & IE conditionals 2014-06-30 14:51:30 -04:00
spf13 b2b7ba4243 fixing typo in docs 2014-06-30 14:49:24 -04:00
spf13 4483a6655a Centralizing the template execution logic in one place 2014-06-06 17:27:31 -04:00
spf13 c297d7451f Adding 'partial' template function to add theme / local awareness to the partials directory. 2014-06-06 16:15:19 -04:00
spf13 4e99d6b54c Adding proper error message when view is not found.. fixing #303 2014-06-04 12:33:27 -04:00
spf13 640ab3c72e fixed #303. Adding theme support to views 2014-06-03 17:53:00 -04:00
Jake Mitchell e0ea6b9955 Support embedding <script> tags in markdown pages 2014-06-03 15:14:38 -04:00
Abe Pazos 7b7ce11787 Add empty line to correctly render a list 2014-06-03 15:09:53 -04:00
spf13 ca18cfef24 Setting new version 2014-06-03 14:39:46 -04:00
spf13 05875153bc Converting front matter to YAML 2014-05-29 18:45:22 -04:00
spf13 2b90779f0f Actually bumping the version 2014-05-29 18:45:21 -04:00
spf13 a3d6e7c46f Fix docs script and css references to refer to the correct location 2014-05-29 18:45:21 -04:00
spf13 012823a32a Update menu documentation to be accurate 2014-05-29 18:45:21 -04:00
spf13 b9bba2b977 Updating Convert to handle dates properly for yaml and json
Fix bug with YAML & JSON with handling dates with 'new' and 'convert'
2014-05-29 18:45:19 -04:00
spf13 0c2544608c Add future details to documentation 2014-05-29 01:02:43 -04:00
spf13 c502f078bc Add handling for publishDates (which will be ignored if in the future). Fixed #260 2014-05-29 00:48:40 -04:00
Rinat Abdullin 4ebaec8906 Include Section Taxonomy into SiteInfo
This allows to build more complex pages, like :
http://martinfowler.com/tags/
2014-05-28 19:31:50 -04:00
spf13 35a605976e SiteInfo is now a pointer on the Node 2014-05-28 19:11:54 -04:00
spf13 7a8b754cad Fixed #301. LiveReload works on any port now. 2014-05-28 19:01:24 -04:00
spf13 4076d77029 Simplifying the siteInfo handling 2014-05-28 18:37:59 -04:00
Phil Pennock 280df4e380 Fix Viperized .Site.Params
git bisect identified 62dd1d4 as the breaking commit; when
github.com/spf13/viper was introduced, the Params field was always
empty.

Given a map in YAML in Viper, the return type is
`map[interface{}]interface{}`, _not_ `map[string]interface{}`, even if
`.SetDefault()` has been called with an item of
`map[string]interface{}{}` so the cast assertion on the `.Get("Params")`
always failed.
2014-05-28 18:15:23 -04:00
Lorenzo Bolla e98f0014f2 Allow to use filename in permalinks 2014-05-28 17:59:49 -04:00
Dan Hersam d65061dffb Adding TechMadePlain to showcase
Thanks to Hugo I get to write all my posts in Markdown.
2014-05-28 17:58:31 -04:00
Rolando Pereira 79767f5617 Fix links to GitHub repo for spencerlyon2/hugo_gh_blog
Hello,

The `github_pages_blog.md` tutorial mentioned links to the git repository of "spencerlyon2/hugo_gh_blog" however it was linking to the page itself (i.e. http://spencerlyon2.github.io/hugo_gh_blog ).

This commit replace those links with links to https://github.com/spencerlyon2/hugo_gh_blog
2014-05-28 17:58:11 -04:00
spf13 1ba63f15c8 Make the header not jump around 2014-05-28 17:54:54 -04:00
spf13 2a44ca543b More doc site improvements. Added documentation's new layout 2014-05-28 01:37:33 -04:00
spf13 79dd1d02b4 Fixing bug with Live Reload where it broadcast instead of sending the handshake 2014-05-27 18:35:12 -04:00
spf13 57ad3abe7b Pre and Post in Menu are type HTML 2014-05-27 18:34:29 -04:00
spf13 a87f171bd4 Updating / Rewriting / Adding all of the documentation in preparation for the next release 2014-05-27 18:32:57 -04:00
spf13 aeb06c7bcc Rename chrome to partials (in builder) 2014-05-27 18:30:25 -04:00
spf13 9173022ea7 Set verbose to Info level 2014-05-27 18:29:55 -04:00
spf13 e799100395 Fix bug so watch works on theme directories as well 2014-05-27 18:29:15 -04:00
spf13 6b8244ba67 new site works in an empty directory now 2014-05-19 09:16:40 -04:00
spf13 df4bbcef30 Adding instant click library to docs so even more responsive navigation 2014-05-16 17:51:10 -04:00
spf13 be1ee22032 Proper integration of live reload with automatic injection 2014-05-16 17:49:27 -04:00
spf13 60ed5bda2b Live reloading is working! Still need to incorporate cleanly. 2014-05-16 11:48:59 -04:00
spf13 296d218e67 Better handling of when the specified port is already in use 2014-05-15 17:41:03 -04:00
spf13 b520f8852d Switching docs highlighting to highlight.js .. Docs build super fast again! 2014-05-15 09:58:55 -04:00
spf13 b198cb26ba Renaming indexes to taxonomies in docs 2014-05-15 09:57:36 -04:00
spf13 a4a1e39a51 Fixing issue when two menu items have the same name. 2014-05-14 18:08:11 -04:00
spf13 4f75ec985d Homepage renders with _default/list.html or then _default/single.html when index.html is not present. 2014-05-13 17:07:50 -04:00
Dato Simó 025a37df2f Fix permalink functionality, which was broken in 62dd1d4.
Viper stores Permalinks as a map[string]interface{}, so the type assertion
to PermalinkOverrides (map[string]PathPattern) will always fail.

We can, however, get Permalinks as a map[string]string, and convert each
value to a PathPattern.
2014-05-12 15:47:52 -04:00
Dato Simó 05b76dcb6f Add a blank line after the front matter when writing back a page.
Could also be done in parser.InterfaceToFrontMatter(), but logically the
extra blank line belongs to the page, not the front matter itself.
2014-05-12 15:46:58 -04:00
Vincent Batoufflet 73cbefdbc8 Make template comparison functions handle floats 2014-05-10 15:38:18 -04:00
Vincent Batoufflet 667a047cea Fix date issue with home page in Sitemap 2014-05-10 15:33:18 -04:00
Dato Simó 0053be979a Correctly print server URL when base-url is specified in the command line
When running hugo server like:

    $ hugo server -s docs -b myhostname

the printed output now directs to http://myhostname:1313 instead of
(invariably) http://localhost:1313.

As per server(), BaseUrl is never empty, and the required value is always
found in Viper.
2014-05-09 23:27:21 -04:00
LK4D4 2194cc77de Add pygmentsstyle and pygmentsuseclasses options
Fixes #204

Conflicts:
	commands/hugo.go
2014-05-09 23:20:11 -04:00
Vincent Batoufflet 5df0cf7eca Add Sitemap documentation content 2014-05-09 23:11:48 -04:00
Vincent Batoufflet 35926dcf37 Add Sitemap testing 2014-05-09 23:11:42 -04:00
Vincent Batoufflet 6049c3a10c Update Sitemap default value syntax 2014-05-09 23:11:37 -04:00
Vincent Batoufflet 2a902bbca6 Add Sitemaps config values handling 2014-05-09 23:11:33 -04:00
Vincent Batoufflet f8e675d064 Add base Sitemap support 2014-05-09 23:11:27 -04:00
Vincent Batoufflet 179225449c Add template comparison functions (Go 1.1 compat) 2014-05-09 22:42:28 -04:00
Marc Liyanage 4e0208d448 Doc fix: replace "hugolibs" with "hugo" in "contributing" page, fixes #271. 2014-05-09 11:36:16 -04:00
Nathan LeClaire c38d694f56 Change some typography in the docs.
Two issues are addressed with this commit:

1. Some <pre> tags were inheriting the "Serif" font on Linux, causing
"code"-ish stuff to appear with proportional-width font instead of
monospaced-width font.
2. Font stack with "Helvetica Neue" ... has been changed to default to
sans-serif instead of "Serif", this produces a more consistent and
friendlier look on Windows in particular.
2014-05-09 11:33:22 -04:00
spf13 ec4b152678 Fixing broken link. Fixed #278. 2014-05-09 11:32:06 -04:00
spf13 9b192e6793 Adding more information about client side highlighting 2014-05-09 00:03:42 -04:00
Dave Cottlehuber bc9f69e7c5 Add client-side syntax highlighting example 2014-05-08 23:45:33 -04:00
spf13 6b9d4a93da Adding new commands (new site [path], new theme [name]) 2014-05-08 18:30:58 -04:00
spf13 be3e5592dc Adding an archetype file for the docs site 2014-05-02 01:06:40 -04:00
spf13 28ffb92b36 Adding the new command and the create package 2014-05-02 01:06:01 -04:00
spf13 08c30b6e44 Using new helpers in page.go 2014-05-02 01:04:48 -04:00
spf13 bff1f1e689 Adding some new methods to helpers (GuessSection, MakeTitle & Filename) 2014-05-02 01:04:14 -04:00
spf13 ef2ad4d91f More feedback where errors happen during metadata conversion 2014-05-02 01:02:49 -04:00
spf13 6d9a2d2497 adding a front matter format to lead rune method 2014-05-02 01:01:44 -04:00
spf13 fb7d45e613 permitting empty files again. Fixing some tests to now pass. 2014-05-01 14:11:56 -04:00
spf13 3395e1cb92 Adding a command that enables converting site to a different metadata format.
Doing this revealed some bugs in the encoding functionality in some of the underlying libraries.
Please backup before using.
2014-05-01 13:23:32 -04:00
spf13 859a78e1bd Providing the ability to save (write) a content's source file. 2014-05-01 13:21:37 -04:00
spf13 1302ef9f63 Making site page initialization a bit more granular and accessible 2014-05-01 13:20:58 -04:00
spf13 cbd9506c29 moving front matter parsing (and creation) to parse package 2014-05-01 13:20:09 -04:00
spf13 58f8b43fee moving writeToDisk to helpers to make it more accessible 2014-05-01 13:13:11 -04:00
Christoph Burgdorf f271faea06 Don't process dotfiles
This commit makes it so that not only files
but also folders which start with a dot
are ignored.

Fixes #239
2014-04-26 23:17:54 -06:00
Ciaran Downey 5581e33a34 Update broken localhost link 2014-04-26 23:08:39 -06:00
William McGann 96b6ae81eb Adding example blog 2014-04-26 23:05:41 -06:00
LordFPL b52e946381 Little syntax mistake 2014-04-26 23:03:20 -06:00
tummychow 2e954d8551 Fix permalinks to subdomains
If you don't have access to the root domain of your site (eg a GitHub project
page) and you try to generate custom permalinks, they must begin with a slash.
Go's URL resolution library sees the leading slash and thinks "this URL starts
at the root", just like a filesystem - so it discards your subdomain and maps
all custom permalinks from the root of your site. Fine if you control the root
domain, not so useful if you don't.

Removing the check for a leading slash fixes this problem. You can now specify
custom permalinks that do not start with a slash, and they will map safely
regardless of what subdomain you upload the generated site under.

Tests have been updated for this commit so that they continue to function.
2014-04-26 23:01:28 -06:00
spf13 bdf7cd9f9d Creating site menu configuration and have the docs site use it 2014-04-24 16:11:08 -06:00
spf13 ac82fe32af Making active parent in nav reflect when child is active page in docs 2014-04-24 10:34:50 -06:00
spf13 ef87dffb2f Fix accidentally removed line from menu template. 2014-04-24 10:28:11 -06:00
spf13 4f813c09ea Fixing some bugs introduced in prior few commits. Tests now pass. 2014-04-24 10:18:47 -06:00
spf13 11fe227b9e Implementing new menu system in the docs site 2014-04-23 03:00:11 -04:00
spf13 9ecf58e29b new menus system including active link & nesting 2014-04-23 02:59:19 -04:00
spf13 69c1944f1f Add handling of deeply nested front matter 2014-04-23 02:55:43 -04:00
spf13 4a8de8ea46 Add Disqus support out of the box. Move template/bundle into hugolib. 2014-04-23 02:53:12 -04:00
spf13 41adafbc3e Updated to work with the latest viper 2014-04-10 14:24:18 -04:00
spf13 8afff8c7c4 Preliminary Theme Support 2014-04-10 08:10:12 -04:00
spf13 c0a046cbfb Added internal rss.xml template and config option to turn off rss creation 2014-04-09 17:45:34 -04:00
spf13 bb9bcdcf30 Add more information to the siteInfo (and configuration options) for better RSS generation. 2014-04-09 17:15:52 -04:00
spf13 93bcddebb3 Renamed Indexes to Taxonomies. Old template and config parameters still work. 2014-04-09 17:15:04 -04:00
spf13 aae6fa0b6b Fix test to not fail when order is different, but slice contents are the same. 2014-04-08 21:57:25 -04:00
spf13 be37c0b37a Adding more articles to press page. 2014-04-08 21:41:01 -04:00
spf13 bd022534bc Adding Params to node for easy template access of page.params without throwing errors. 2014-04-08 21:40:38 -04:00
spf13 c8269d6dbc Making node.Keywords the correct length 2014-04-08 21:40:03 -04:00
Michael D. Johas Teener 4161d542ce Misc doc fixes
* Pygments links and requirements for installation.
  * Fix to link to additional template functions in release notes for
v0.10
2014-04-08 11:30:11 -04:00
spf13 d1c500c124 Adding Press page to hugo docs 2014-04-07 23:47:21 -04:00
spf13 af1acfbce7 writing indexes under more configuration conditions 2014-04-07 23:29:35 -04:00
spf13 ad34be9d77 strip trailing baseurl slash. Added a new template function "sanitizeurl" which ensures no double slashes. Fixed #221 2014-04-07 22:02:08 -04:00
ojan a6170154cf add: yslow-rules showcase 2014-04-07 11:44:51 -04:00
spf13 9a83f7a01b Fixing all tests to pass with new Viper Config 2014-04-07 11:44:51 -04:00
spf13 62dd1d45c1 Hugo config abstracted into a general purpose config library called "Viper".
Hugo casting now in own library called "cast"
2014-04-05 01:40:33 -04:00
Stephen Eglen a01056b98a typos in mathjax.md
Fix some typos.
2014-03-31 14:31:39 -04:00
Spencer Lyon a7ca39ccd7 ENH: added tutorial for hosting a blog on github pages 2014-03-31 14:26:58 -04:00
Zach Chadwick 2e4158b0b4 added appliance.cloudshark.org to showcase
also cleaned up thumbnail view to not show source link if unavailable
2014-03-31 13:35:15 -04:00
spf13 e50b9d8ac1 Adding support for logging & verbose logging. Consolidation of error handling. Integration of jWalterWeatherman library. Fixed #137 2014-03-31 13:23:34 -04:00
Spencer Lyon 2fa3761ec9 DOC: added tutorial for using MathJax with Hugo 2014-03-24 15:11:54 -04:00
Nate Finch c02a02070f change golang to go 2014-03-24 14:34:41 -04:00
Tim Heaney 5ee0a3b9a1 Typo: s/executible/executable/ 2014-03-24 14:33:16 -04:00
spf13 895fe536fd Adding a few more logos and powered by/made by images. 2014-03-24 14:32:38 -04:00
spf13 f733e70e80 Adding apple touch & favicon meta links 2014-03-24 14:32:03 -04:00
spf13 51b078a703 Homepage update. New Logo. Minor site updates. 2014-03-20 21:51:14 -04:00
spf13 6205a16b6e Fixes #227 by properly scoping the variables within the go routine. 2014-03-13 20:34:47 +01:00
Alexandre Normand 85c04ca2f3 Add Tutorial With Steps to Migrate from Jekyll. 2014-03-13 12:23:33 +01:00
spf13 7135d897a2 Optimizing thumbnail & preview images 2014-03-13 12:07:22 +01:00
Alexandre Normand 17fdf7d604 Add www.heyitsalex.net to Community Showcase. 2014-03-13 12:02:14 +01:00
GuoJing 1b3525d638 fix typo of readme 2014-03-13 12:01:00 +01:00
Alex Dunn 38131837ba clearer pseudo command in quickstart doc
- previously it was ambiguous between the actual Step 1 and the "step 1" of the steps *within* Step 2 ("Clone into the hugo repository")

- also fixed a typo I guess
2014-03-13 11:59:36 +01:00
Ruben d5c58b457f Order ByTitle and ByLinkTitle added
Added documentation for new order possibilities
2014-03-13 11:39:19 +01:00
Ruben eec0e512f9 Add sort pages by Title and by LinkTitle
Sorting can now be done on Title and on LinkTitle
2014-03-13 11:39:13 +01:00
spf13 3dfb475136 Parallelizing the largest build processes (templates, pages, indexes). Seeing 300%+ improvement of total build time. 2014-03-05 23:48:42 -05:00
Joe Kopena d84f707da1 Also ignore Emacs lock & recovery files. 2014-03-04 22:07:40 -05:00
spf13 3a0ab5a3dd Bumping version to v0.11-dev 2014-03-04 22:03:31 -05:00
spf13 0447c7598b Adding the right date for the release of 0.10 2014-03-01 12:16:36 -05:00
spf13 0a775650b5 bumping version for 0.10 2014-03-01 11:55:05 -05:00
Mike Keesey 2540d884d8 Fixing issues go vet reports. 2014-03-01 09:56:17 -05:00
Ask Bjørn Hansen 2c0ded7f9f Add test for ignoring ~$ files 2014-02-28 23:24:09 -05:00
Ask Bjørn Hansen e53bc948a5 Ignore content files ending in ~
Also add *~ to .gitignore
2014-02-28 23:23:59 -05:00
Ask Bjørn Hansen 0becad727a Make error message when encountering unrecognized file extensions more helpful 2014-02-28 22:11:41 -05:00
Ask Bjørn Hansen ea8d0981d5 Make per-page url overrides take precedence over section permalink settings
This seems more reasonable to me.

I didn't understand why the pUrl comparision was on len > 2; I changed it to 0.

Closes #212.
2014-02-28 11:55:37 -05:00
Kieran Healy 732b5d42b2 Add Kieran Healy's website. 2014-02-28 11:50:19 -05:00
spf13 ae954d5165 updating the intro page 2014-02-28 11:41:47 -05:00
spf13 14227351fa Reorganization of helpers. Centralized Url/Path logic. Fixed #175. 2014-02-27 20:33:18 -05:00
spf13 64572d2d60 Shortcode cleanup. Added a ton of tests. Much more flexible with input. Doesn't crash with bad input. Fixed #193
Also added the .Get function to short codes and documentation for that function.
2014-02-25 23:57:31 -05:00
spf13 dc068ccb87 Fix imports so hugo builds on darwin 2014-02-21 18:33:46 -05:00
spf13 8fe78f6ff5 A bunch of small documentation changes 2014-02-21 09:48:37 -05:00
spf13 de05a0d942 Adding documentation on Pretty Urls 2014-02-20 19:04:29 -05:00
spf13 e74d1b8607 Adding documentation on Table of Contents functionality 2014-02-20 19:04:08 -05:00
spf13 30e804eee5 Adding an introduction to Hugo 2014-02-20 19:03:37 -05:00
Ask Bjørn Hansen 82fdfa2c72 Warn about bad shortcode parameters (and don't crash)
closes #193
2014-02-20 06:54:56 -05:00
spf13 5cff3e6219 Adding Else If example 2014-02-19 09:24:04 -05:00
Ask Bjørn Hansen ed0fe9ddf7 Make 'read a string' code understand float64 (json) and int (yaml) as well as actual strings 2014-02-18 18:44:56 -05:00
Ask Bjørn Hansen b41622bc49 Allow 1/0 for true/false in Yaml front-matter 2014-02-18 18:44:47 -05:00
Ask Bjørn Hansen e4af4f652e Support ISO8601 date/time format without timezones 2014-02-18 18:44:40 -05:00
Ask Bjørn Hansen 0bfe9276c2 Make the invalid date/time format error message more helpful 2014-02-18 18:44:32 -05:00
Ask Bjørn Hansen 1dbed5ee06 Call the json delimiter 'json_lead' instead of 'java_lead' 2014-02-18 18:44:27 -05:00
mattn 8ebb85f1f7 Fix build 2014-02-18 18:40:55 -05:00
spf13 1bead0ed7a Adding Documentation on using Syntax Highlighting 2014-02-18 18:35:45 -05:00
spf13 56dfdfe86c Adding Documentation on Hugo Template Functions 2014-02-18 18:35:27 -05:00
spf13 bf6407759b Minor Docs Tweaks 2014-02-18 18:35:03 -05:00
spf13 8008675983 Adding Go Template Tutorial 2014-02-18 18:34:51 -05:00
spf13 dca7a90181 Updating Release Notes and Roadmap 2014-02-18 18:34:29 -05:00
spf13 75c260fa1c Only change rLimit on OSX (where it is needed). Fixed #194 2014-02-06 00:12:05 -05:00
Anton Ageev 11ca84f8cb Add unicode support for aliases, indexes, urlize template filter.
Now aliases and indexes are not restricted ASCII letters and can include
any unicode letters.
2014-02-05 11:49:57 -05:00
Ant Zucaro 24ffe04360 Add Ant Zucaro's showcase.
A photography-oriented blog using Foundation 5 by Zurb. Responsive
layout with padded large and full-width small views. A sample
"polaroid" shortcode is included for image showcases, as is a
"header" image directive in the frontmatter.
2014-02-05 11:46:53 -05:00
Luke Holder 5cfb690e31 Fix docs error with json comma 2014-02-03 13:50:28 -05:00
Anton Ageev 72ba6d633d Fix permalink bug in uglyurls mode (refs #187). 2014-02-02 00:56:01 -05:00
spf13 3e87d7a86e Automatically increase the process ulimit to maximum available. fixes #168. 2014-02-01 12:51:11 -05:00
spf13 ae9cc09b04 Adding the ability to check the system limit on open files (important for watching large sites) 2014-02-01 12:50:17 -05:00
Niels Widger c1b9380dfd Add back blackfriday extensions during Markdown conversion
Modified markdownRender and markdownRenderWithTOC in hugolib/page.go to
use the same flags and extensions as were previously used when we simply
called blackfriday.MarkdownCommon to convert Markdown to HTML.  These
flags/extensions were dropped during the refactor that added the
`.TableOfContents` page variable, and caused features like Markdown
tables to no longer work.

Modified the expected output for TestTableOfContents in page_test.go,
apparently changing the flags/extensions caused an `&mdash;` to become
`&ndash;`.
2014-01-30 23:04:37 -05:00
Tibor Vass 6dd2e9a49a gofmt all go code 2014-01-29 18:03:35 -05:00
Vincent Batoufflet ff9f6e1b2a Fix panic with HTTP serve initialization problems. 2014-01-28 23:44:43 -05:00
Vincent Batoufflet 0ce6f05f59 Add text transformation template functions. 2014-01-28 23:44:23 -05:00
spf13 18b9948f1e Using table of contents within the documentation. 2014-01-28 23:29:05 -05:00
spf13 1882ffabc6 Adding support for boolean params 2014-01-28 23:24:59 -05:00
spf13 1da3fd039a Continue with TOC integration and page refactor. Updated a few tests to match new generated output. 2014-01-28 23:11:05 -05:00
spf13 f45c6bc38a Moved TOC test into page_test. Some general page_test cleanup. 2014-01-28 23:09:24 -05:00
spf13 9666f33e2f Don’t render short codes on summary twice 2014-01-27 17:32:36 -05:00
spf13 f82c645b33 fixing 178. 2014-01-27 17:20:35 -05:00
spf13 d0825a211a Big refactor of pages code. Changed TOC code to only parse when actually used 2014-01-27 17:20:20 -05:00
Niels Widger f62e3e9940 Add new TableOfContents Page variable (Markdown only)
Added TableOfContents field to hugolib.Page struct.  New function
getTableOfContents is used in convertMarkdown to set the TableOfContents
field.

Added new test file hugolib/page_toc_test.go with a simple test of the
new functionality.

Conflicts:
	hugolib/page.go
2014-01-23 17:27:08 -05:00
spf13 4f1807c7a7 Replacing hall of fame with showcase. (new type, content driven, thumbnails, etc) 2014-01-22 17:16:09 -05:00
spf13 9564e6e9d8 Adding support for some primitive template math functions 2014-01-22 17:06:23 -05:00
Andrew Codispoti 0e013b5291 add andrewcodispoti.com to hall-of-fame 2014-01-22 15:24:11 -05:00
spf13 3851117c25 renaming MinRead to ReadingTime and adding to documentation. 2014-01-21 20:08:24 -05:00
spf13 50a7f97a62 Updating page variable documentation (for templates). 2014-01-21 20:07:55 -05:00
spf13 f0634ec059 fixed #171. RSSlink is now RSSLink (and matches existing docs).
Added backwards compatibility accessor for existing templates.
2014-01-18 22:16:19 -05:00
spf13 ae15ff0968 Fixing test which erroneously checked values and order, rather than just values. 2014-01-18 21:26:34 -05:00
spf13 44186c6af1 Extending rss item limit to 50… can reduce further in template with ‘first N’ functionality. 2014-01-18 21:18:54 -05:00
spf13 fa2e58fd4a Have travis build with latest go. 2014-01-18 11:05:50 -05:00
spf13 cb04053385 RSS improvements, now limit to 15 items and provide accurate date. fixed #172 2014-01-18 11:05:50 -05:00
spf13 303be735fb Adding github button to docs homepage 2014-01-18 11:05:50 -05:00
Steve Francia c51d040e3d Adding Werker status to readme 2014-01-15 11:06:41 -05:00
Steve Francia 845d09763a Create wercker.yml 2014-01-15 11:02:24 -05:00
Brandon Philips f8243624e4 feat(docs/hall-of-fame): add ifup
Add me! Thanks for hugo, working great.
2014-01-13 10:06:32 -05:00
Phil Pennock 438c219892 Add canonifyurls config option.
Be able to inhibit AbsURL canonicalization of content, on a site
configuration basis. Advantages of being able to inhibit this include
making it easier to rendering on other hostnames, and being able to
include resources on http or https depending on how this page was
retrieved, avoiding mixed-mode client complaints without adding latency
for plain http.
2014-01-13 10:06:12 -05:00
spf13 2ff108fcb7 Add highlighting of code in documentation and clean up a bunch of the docs. 2014-01-10 21:29:58 -05:00
spf13 13b5c10dd7 Rewriting some homepage text 2014-01-10 21:29:58 -05:00
spf13 74d7ae1f8f A bunch of style updates. Switching to bootstrap carousel. 2014-01-10 21:29:58 -05:00
spf13 01da9a40e6 Report error, but don’t fatally stop if pygments has error. Return original string. (+1 squashed commit)
Squashed commits:
[849a7af] if highlighting doesn’t work, just return original string
2014-01-10 21:28:48 -05:00
spf13 3fd6c1a24e Adding some embedded short codes (including code highlighting) 2014-01-10 21:27:32 -05:00
spf13 13b067b506 Adding support for embedded templates 2014-01-10 21:27:32 -05:00
spf13 f78e2cb854 Removing Twitter js 2014-01-10 21:27:32 -05:00
spf13 a70acd110e New Icon Font for Hugo 2014-01-10 21:27:32 -05:00
Steve Francia 247db151fa Adding some analytics 2014-01-03 12:58:09 -05:00
Dana Woodman b82baa285b Adding chimeraarts.org to hall-of-fame
I've added the website for the makerspace I founded into the hall of fame list as an example of what you can do with Hugo.

It's a work in progress (like everything) but should show people another example of using Hugo in the real world.

Hugo has made it much easier to update our website content without needing to use bloated or expensive tools.

Thanks!
2013-12-31 22:45:47 -05:00
Krisztián Szabó 5550c4148e Added append-port flag 2013-12-28 22:01:36 -05:00
William King e5aa08ff0c If baseurl is set then print that on the command line, else leave as default of localhost
Conflicts:
	commands/server.go
2013-12-28 14:02:10 -05:00
Egon Elbre 8b84156f87 Example of a multilingual site. 2013-12-28 13:48:15 -05:00
spf13 8055838c70 Allowing empty files (ignored) so you can touch a new file while watching 2013-12-28 13:47:34 -05:00
Egon Elbre 1c60d5bf20 Don't shutdown hugo on an empty file. 2013-12-28 13:47:21 -05:00
Egon Elbre 8d80f9b39e Added batching behavior for page building.
Quite often file watcher gets many changes and each change triggered a
build. One build per second should be sufficient. Also added tracking for
new folders.
2013-12-28 13:46:52 -05:00
Egon Elbre 1979f7d9c7 Avoid locking the files for an extended amount of time. Sublime Text
doesn't like this and shows an error when modifying a file in rapid
succession.
2013-12-28 13:46:09 -05:00
Egon Elbre e46148f948 Fix static file change detection on Windows.
Fixed windows uses different filepath separator. The filepath.ToSlash
shouldn't be used, because it can cause errors in filepath suffix and prefix
testing since "c:\a" isn't a prefix of "c:/a/b/c".
2013-12-28 13:45:38 -05:00
spf13 065928fcf0 Adding page sorting by weight function (the default) 2013-12-28 12:56:12 -05:00
spf13 34ac562ce4 Added documentation on ordering indexes, content and content within indexes 2013-12-20 18:11:49 -05:00
spf13 70745e8cb5 Complete refactor of indexes, move (and rewrite) page sorting to page.go, add tests 2013-12-20 09:10:05 -05:00
Henry 6aa3e51228 Added PageSorter and PagesByDate 2013-12-16 17:55:37 -05:00
Ruben c7083a5d36 Section in example was wrong for happiness.md 2013-12-16 17:43:53 -05:00
Ruben 950d9f55a5 Testcases for multilevel structure were wrong 2013-12-16 17:43:53 -05:00
Ruben de670ced86 Fixes #141: Wrong section in multi level structure 2013-12-16 17:40:33 -05:00
Caleb Spare 6da23f7449 Gofmt
Command: `gofmt -l -s -w .`
2013-12-16 17:40:10 -05:00
Matt Way 1abc2f0b86 properly use non-localhost BaseUrl in server command 2013-12-16 17:39:59 -05:00
spf13 a10519643d Adding better contribution guidelines from the read me to the contribution page. 2013-12-10 22:34:13 -05:00
spf13 dd574628a0 Adding community section to the documentation 2013-12-10 22:34:13 -05:00
spf13 ceb708052a Adding selected tweets to the homepage 2013-12-10 22:34:13 -05:00
spf13 f09505a657 Adding example short codes to the documentation 2013-12-10 22:34:13 -05:00
Noah Campbell 6410965b97 Add go fmt to contribution guidelines
Also fixed up formatting.
2013-12-07 20:51:34 -08:00
Noah Campbell 357ab956ea Add Contribution Guidelines
Fixes #122
2013-12-07 20:48:17 -08:00
spf13 0e04b9a029 Moving processing short codes to the page 2013-12-06 23:57:24 -05:00
spf13 d0ef3d43bd better handling of detecting markup format 2013-12-06 23:56:51 -05:00
spf13 f432b187a0 render shortcodes prior to converting to html 2013-12-06 23:32:00 -05:00
spf13 a45de56db1 adding support for shortcodes with opening and closing tags 2013-12-06 23:14:54 -05:00
spf13 db29f57cc4 Adding (source code) Highlight template helper 2013-12-05 09:43:49 -05:00
spf13 fa29e94edb Adding Pygments helper 2013-12-05 09:42:29 -05:00
spf13 44d57fdc0c Reorganize helpers 2013-12-05 09:29:41 -05:00
David Arroyo 10c7cf2942 Create directories in publishdir with mode 0777.
The previous permissions (0764), were unusable (directories must
be executable) when generating files for use by another uid. The
Right Thing™ is to use mode 0777. The OS will subtract the process
umask (usually 022) to the for the final permissions.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-12-02 16:06:31 -08:00
David Gay ba5dadff79 Typo fix in docs.
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-23 20:41:54 -08:00
Valeri Karpov 32d9345bba Fix a minor typo in types.md
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-23 08:49:08 -08:00
Javed Khan b351731f72 quickstart docs - fix flag needs arg error
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-23 08:47:25 -08:00
Tim Esselens 860f982cc4 fixed trailing dir slash when using slug
See testcase, dir + slug contained double slash when dir had a trailing
slash.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-20 15:32:22 -08:00
Phil Pennock e425226a28 Documentation updates, mostly for my bits
* extras/permalinks.md added, weighted to third in the extras menu
* examples added to layout/go-templates.md, using `.Site.Params`
* mention `.Site.Params` in layout/variables.md
* update meta/release-notes.md to mention `first` and the permalinks
* update overview/configuration.md to use reserved-for-documentation
  domains and with another example, nudging towards permalinks and site
  parameters, with three different data-types shown for the latter

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-18 15:51:31 -08:00
Phil Pennock 07978e4a49 configurable permalinks support
A sample config.yaml for a site might contain:

```yaml
permalinks:
  post: /:year/:month/:title/
```

Then, any article in the `post` section, will have the canonical URL
formed via the permalink specification given.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-18 13:32:56 -08:00
spf13 4f335f0c7f Updated release notes. 2013-11-15 23:47:53 -05:00
spf13 445b7d23fb Updating docs to include ‘first’ functionality for the homepage 2013-11-15 21:45:52 -05:00
spf13 aedfa6a2c4 Version bump 0.9 2013-11-15 21:43:46 -05:00
spf13 ad2c0b5616 Homepage now has all content available, use sorting and first to control rendering 2013-11-14 09:37:58 -05:00
spf13 13fa7cb748 lowercase template function first to be consistent with all other template functions 2013-11-14 09:32:49 -05:00
Michael D. Johas Teener 50d9046b64 remove initialization loop error from compile
copied HugoCmd to a local var, initialize that variable in the init
func, and then use the local var in the InitializeConfig func.
2013-11-12 17:36:23 -06:00
Phil Pennock 40d05f12a7 Truncated; .Site.Params; First function
* Add `.Truncated` bool to each page; will be set true if the
  `.Summary` is truncated and it's worth showing a "more" link of some
  kind.
* Add `Params` to the site config, defining `.Site.Params` accessible
  to each page; this lets the site maintainer associate arbitrary data
  with names, on a site-wide basis.
* Provide a `First` function to templates:
  * Use-case: `{{range First 5 .Site.Recent}}` or anything else which
    is a simple iterable provided by hugolib
* Tests by me for `.Truncated` and `First`

Also @noahcampbell contributed towards this:

* Add UnitTest for `.Site.Params`:
> Digging into this test case a bit more, I'm realizing that we need
> to create a param test case to ensure that for each type we render
> (page, index, homepage, rss, etc.) that the proper fields are
> represented.  This will help us refactor without fear in the
> future.

Sample config.yaml:

```yaml
title: "Test site"
params:
  Subtitle: "More tests always good"
  AuthorName: "John Doe"
  SidebarRecentLimit: 5
```

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-11-12 22:49:54 +00:00
spf13 6017599a3c restored behavior of respecting config values unless set by command flags. fixed #116 2013-11-12 09:38:43 -05:00
Noah Campbell ef595aedfc Handle schema-less urls when apply absurl
Fixes #114
2013-11-09 14:35:09 +00:00
spf13 90a902c843 fixing double slash during absurlify 2013-11-09 01:33:00 -05:00
spf13 b69694a3ae Merge branch 'master' of github.com:spf13/hugo 2013-11-09 01:17:40 -05:00
spf13 532e2e7b93 Some mobile and other fixes for docs 2013-11-09 01:16:34 -05:00
Steve Francia 0b6a11c9e3 Merge pull request #113 from oyvindsk/master
minor documentation fix
2013-11-07 16:33:06 -08:00
Øyvind Skaar adc559b09f minor documentation fix 2013-11-07 19:47:42 +01:00
Noah Campbell ad04f6c899 Adding baseline 2013-11-05 22:51:40 +00:00
Noah Campbell 86233c00a0 Remove the hugo-nav function
Remove the hugo-nav since it relied on a slow library.  The current
build reimplements the absurl functionality based on string replace.
Discovered that my prior implementation missed the requirement for
making absolute paths (/path) absolute with the host, whereas a relative
path is left untouched.  Updated the test cases to support this if this
is reimplemented.
2013-11-05 22:28:06 +00:00
Noah Campbell 1cebce12ad Adding RSS test case.
Checks to make sure the xml document starts with <?xml.  Previously, the
html translate package would write additional details into the document
that caused it to fail.
2013-11-05 07:03:02 +00:00
Noah Campbell b22364570b Fix Test Name 2013-11-05 06:39:50 +00:00
spf13 1fbcaf9279 Buffers instead of pipes 2013-11-05 00:28:08 -05:00
spf13 226bc8f59f Updated release notes 2013-11-05 00:24:04 -05:00
Noah Campbell 23a5711d26 Fix benchmark panic
Need to initialize the Config with InitializeConfig().
2013-11-01 20:36:11 -07:00
spf13 23a711a29a Hugo updated to work with latest cobra 2013-11-01 18:43:41 -04:00
Noah Campbell 9af47f07d3 Improve rendering time
50% speedup.  Fix #91

to run the benchmark:

		go test -test.run=NONE -bench=".*" -test.benchmem=true ./transform/ > new.txt

to compare the results:

		/usr/local/go/misc/benchcmp baseline.txt new.txt

Speedup and memory improvements

		benchmark             old ns/op    new ns/op    delta
		BenchmarkChain           101219        50453  -50.15%
		BenchmarkTransform        51625        45531  -11.80%

		benchmark            old allocs   new allocs    delta
		BenchmarkChain              222          103  -53.60%
		BenchmarkTransform          135          106  -21.48%

		benchmark             old bytes    new bytes    delta
		BenchmarkChain            23919        10998  -54.02%
		BenchmarkTransform        11858        10665  -10.06%
2013-11-01 09:59:57 -07:00
Noah Campbell f4cb8e1688 Adding benchmark for transformation module. 2013-11-01 09:59:57 -07:00
Noah Campbell 789aa6ad76 Removing check for directory: static, layouts
Removed these checks so a single file in content can generate a site.

For example, given a site with a content directory and an index.html,
running hugo -s dir will generate a project without any more input.
2013-10-31 16:06:24 -07:00
spf13 861472bea5 Small tweaks to Homepage and CSS 2013-10-31 09:51:42 -04:00
spf13 1d0d280e20 Addition of an indexes section to the docs. Updated most of the existing index content. 2013-10-31 09:51:13 -04:00
spf13 a7dae30a8f More work on indexes 2013-10-31 09:49:29 -04:00
spf13 bc7c9221f3 Better mobile support on docs site 2013-10-26 02:28:25 -04:00
spf13 90355eec79 Big visual overhaul of the docs. Docs now using indexes for all menu generation. 2013-10-26 02:18:14 -04:00
spf13 df0523ff7f Flipping around weight order. higher weight at the bottom. use negative to pin to top. 2013-10-26 00:20:48 -04:00
spf13 5003f7f7af Docs menu now powered by indexes.. converting some of the content to use this. 2013-10-25 18:42:46 -04:00
spf13 d20b41a2cf Big index overhaul. Now supporting ordering tokens by count or alphabetically. Also made full indexes available to the Site variable. 2013-10-25 18:40:55 -04:00
spf13 9388f23606 Adding support for linkTitles 2013-10-25 18:37:53 -04:00
spf13 b580a25d1f Better error handling when rendering error found when in watch mode
In watch mode it should continue to watch for changes, in any other mode it should exit with a -1 error code so can check for success when scripting
2013-10-25 18:03:14 -04:00
spf13 764abd2067 Update homepage 2013-10-24 16:49:17 -07:00
spf13 dde965a5cd Migrate docs to Bootstrap 3.0 2013-10-24 16:49:01 -07:00
spf13 cd71eb7389 Watching doesn't built site 2x on write (ignores rename events). Also ignores temporary files written by editors. 2013-10-24 16:45:24 -07:00
spf13 a5606b06ca Adding support for ordering content in indexes by other than date (weighted indexes) 2013-10-24 15:24:47 -07:00
spf13 471fb1ff69 Adding support for date field in front matter as date (as TOML provides) 2013-10-24 15:18:57 -07:00
spf13 f3c816eabd Adding support for more front matter types (int, float & date) 2013-10-24 14:31:04 -07:00
spf13 3558e3d6f0 Add support for weighted pages
Now pages can be sorted by other than date
2013-10-18 11:01:31 -04:00
spf13 90090175f8 Adding preliminary support for weighted indexes (for ordering by other than date) 2013-10-17 23:57:25 -04:00
spf13 678ddef46a Adding a quick start guide to hugo docs 2013-10-17 22:53:04 -04:00
spf13 4d333e81ee New Homepage for Hugo 2013-10-17 22:52:28 -04:00
spf13 4263094d75 Adding support for MinRead. Closed #106 2013-10-15 09:32:21 -04:00
spf13 be5ace1588 Wordcount restored. fixed #92 2013-10-15 09:15:52 -04:00
spf13 e58d8fe791 fixed #95, fixed #93 2013-10-09 23:38:51 -04:00
spf13 f5fda80486 simplified buildSite & better error handling around it 2013-10-09 19:14:26 -04:00
spf13 0318f7c149 Clean up server & build site logic. Fixed #94 2013-10-09 18:53:46 -04:00
spf13 e6ace71fec server command now builds prior to serving 2013-10-09 18:24:40 -04:00
Noah Campbell 4993152dda Permalink to include multiple directories levels 2013-10-08 18:44:15 +02:00
Noah Campbell 6e1268f45b Test case for permalink functionality 2013-10-08 18:44:15 +02:00
Noah Campbell 895638433e Adding back the hugo homepage.
Deleted the page accidentially
2013-10-08 18:44:15 +02:00
Noah Campbell 9500ec1b6b Refactor layout selection code
The render code path would use a fallback if there was an exception.
This change instead relies on explicit declaration of the layout to use
and includes a check to see if the layout indeed exists before
attempting to render it.
2013-10-08 18:44:15 +02:00
Noah Campbell 197aacb647 Add support for Relative Permalinks 2013-10-08 18:42:03 +02:00
Noah Campbell 06da609138 Refactor Permalink to private function
This will allow for reuse of this particular function.
2013-10-08 18:42:03 +02:00
Noah Campbell 6fa6f69a4a Change transformer order 2013-10-08 18:42:03 +02:00
Noah Campbell d712d6f331 Moving transformation on a per-page level 2013-10-08 18:42:03 +02:00
Noah Campbell 9032a228b0 Better handle missing layouts
Panic is too extreme.  Instead the library will write out a message in
verbose mode.
2013-10-08 18:42:02 +02:00
Noah Campbell 54a2790fce Use io.Pipe for chaning render tasks.
Also clean up logic for finding layouts.
2013-10-08 18:42:02 +02:00
Noah Campbell 689cda1740 Code cleanup 2013-10-08 18:40:41 +02:00
Noah Campbell 19cb6c7819 Move writing next to rendering
All render(Thing) calls have a WritePublic call directly after it.  This
refactor creates one function that makes the specific call sequence.
2013-10-08 18:40:40 +02:00
Noah Campbell 2176d2c197 Reducing scope of RenderThing* 2013-10-08 18:37:50 +02:00
Noah Campbell ff8b52758d Move in memory target into target module. 2013-10-08 18:37:50 +02:00
Noah Campbell 80009b427f Change the order of Apply to be more Unixy
Typically the destination is on the left and the src is on the right.
2013-10-08 18:37:50 +02:00
Noah Campbell 94a3184ad0 Fixing up source code formatting. 2013-10-08 18:37:50 +02:00
Noah Campbell 5a66fa3954 Chain transformers and test cases
Transformers can now be chained together, working on the output of the
previous run.
2013-10-08 18:37:50 +02:00
Noah Campbell eb117eb904 Move AbsURL into seperate file 2013-10-08 18:37:49 +02:00
Noah Campbell f0211b84a1 Rename Transform to AbsURL 2013-10-08 18:37:49 +02:00
Noah Campbell 03d1a57fea Set the name of the Nav attribute to select 2013-10-08 18:37:49 +02:00
spf13 5e14af957a Proper handling of 404 page return value 2013-10-07 09:24:13 -04:00
spf13 7468292c4e Fixing bug where RSS for site was rendered in wrong location 2013-10-07 09:23:42 -04:00
spf13 d829e05036 Fixing bug where only the first index list was created. 2013-10-07 09:07:14 -04:00
spf13 2aaf92b515 Summary can now contain short codes when using <!--more--> to define end of summary. 2013-10-04 16:07:24 -04:00
spf13 be7ba0e98f server defaults to localhost unless overridden by command line flags 2013-10-04 16:03:13 -04:00
spf13 266f583a8c Restoring former snippet behavior & adding test to ensure future behavior 2013-10-04 12:28:28 -04:00
spf13 dcfcbac589 Enabling Nitro ('--stepAnalysis') again. Fix #58 2013-10-03 09:44:45 -04:00
spf13 18f2b82658 Switching to the rjson library which is more friendly to human generated json. 2013-10-01 22:45:24 -04:00
spf13 48e1068e3e fixed #85 2013-09-30 22:40:15 -04:00
spf13 8efb90ebd5 Updating usage documentation to new interface 2013-09-30 22:39:06 -04:00
spf13 3ae8dda203 Restoring build and watch functionality 2013-09-30 22:38:32 -04:00
Kyle Mahan aa9b9d596e minor documentation cleanup.
- changed it's -> its where appropriate.
- added post/ parent directory above happy/ to the organization examples

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-29 19:50:25 -07:00
windch 8ce4bc7ab8 Update filesystem.go
bugfix: .Files() called twice in line 253, 256 in site.go. thus source files captured twice.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-29 19:43:38 -07:00
spf13 94d7fe52f8 Change the interface to use commands and flags instead of just flags.
Better organization of main (controller style) code.
2013-09-29 02:10:29 -04:00
spf13 92cff05582 go fmt so code 2013-09-29 02:10:29 -04:00
spf13 ff2b98c9dd Better error message when no source content is found. 2013-09-29 02:10:29 -04:00
Noah Campbell f34ea6108d Add the ability to set navbar li class to active
First cut at doing post html processing.  This utility can be used to
mark pages as active.
2013-09-28 23:05:16 -07:00
Noah Campbell db50154e75 Support index.html indexes in content directory
If a file named index.html exists in a directory, or root, it will be
rendered as if ugly urls are turned on.  This allows for top level
content to not need a supporting layout file and content in content.
This change should not affect anyone who is using the perscribed way.

I also cleaned up a bunch of one off functions in site.go.
2013-09-24 21:27:25 -07:00
Noah Campbell 4250bf8e30 Fixes #80 - Homepage now renders correctly
I mistakenly make RenderHomePage a NOP.  Bad programmer.
2013-09-24 14:41:21 -07:00
Noah Campbell c9223cfd7b source: Fix failing build on windows
The +build directive was not being picked up.  Apparently needs a space
after the +build line.
2013-09-24 14:36:22 -07:00
Noah Campbell 8df88496e2 Fix breaking test cases on unix platform
Rename platform parameter file to agnostic name. Both darwin and linux
can share the same paramters.
2013-09-20 20:08:52 -07:00
Noah Campbell bffe4baf42 Create a TargetPath() method that provides OutFile
Moved the generation of the target path to the page breaking all
dependecies on Site.
2013-09-20 17:24:25 -07:00
Noah Campbell 52e8c7a0ac Section is determined by the source, not the url
This change allows for top level html content to exists.
2013-09-20 17:03:43 -07:00
Noah Campbell 784077da4d Fix fragments being AbsUrlified in final html
Found that fragments were getting the BaseURL applied creating a proper
anchor url and redirecting off the page.
2013-09-18 15:48:36 -07:00
Noah Campbell 311e102223 Allow non-markdown content in content directory
Allow content that is not markdown and does not need to be rendered to
exists in the content directory.  Currently any valid html or xml
document can exist.  Templates are applied to these documents as well.
If you need to have content that doesn't have templates or AbsUrlify
like operations, then continue to put this content in static and it will
be copied over.
2013-09-18 14:21:27 -07:00
Noah Campbell 5374242ff7 More expressive --check output 2013-09-18 11:52:30 -07:00
Noah Campbell c510140c0c Add renderer information to --check
Now reports if the page will be rendered or not and by which render
engine.
2013-09-18 10:27:56 -07:00
Noah Campbell 67b2abaf09 Add IsRenderable to Page
As pages are read from the target, they will be assessed if they should
be rendered or not.  The logic for IsRenderable is in the parser/page.go
and looks for anything exception '<'.
2013-09-18 10:17:43 -07:00
Noah Campbell d8e1834910 Fix parsing edge case of frontmatter
When the frontmatter contains a - (or other delimiter) close to the
closing frontmatter delimiter, frontmatter detection would fail.
2013-09-18 09:15:46 -07:00
Noah Campbell a82efe5bb1 Merge remote-tracking branch 'origin/parser' into mrg_praser
Also brought in parse for github.com/noahcampbell/akebia

Conflicts:
	hugolib/page.go
	hugolib/page_test.go
2013-09-17 15:52:40 -07:00
Noah Campbell 6b0752e8c0 Move AbUrlify to post content transformation
Currently the a@href and script@src elements will have BaseUrl applied
to their elements prior to being written to disk.
2013-09-17 14:16:06 -07:00
Noah Campbell c6fe87b14e Add a transform step
This allows for the manipulation of the DOM.  This is expected to be
applied after the templates are rendered.
2013-09-17 13:04:28 -07:00
Noah Campbell c75da346e1 Fix alias documentation.
Fixes #79
2013-09-13 16:06:39 -07:00
Noah Campbell 172ff5ea7a Initialize HTMLRedirectAlias before ShowPlan()
Without it, no alias information is generated when running --check
2013-09-13 15:06:37 -07:00
Noah Campbell d45fb72f67 Add /index.html to unadorned alias paths
Bring code to be better in line with documentation.
2013-09-13 14:51:28 -07:00
Noah Campbell 803a0fce1e Remove RenderedContent from page.
The output is written directly to disk after being written.  Not
entirely sure why it was split into two steps.
2013-09-13 10:30:27 -07:00
Noah Campbell 2ebfb33fe0 Move alias logic to target module
I want to move all logic to writing aliases to target so I can pave the
way for writing aliases specific to other runtimes (like .htaccess for
apache or a script for updating AWS or symlinking on a filesystem).
2013-09-12 21:20:00 -07:00
Noah Campbell 2f10da1570 Move alias rendering to target 2013-09-12 16:18:30 -07:00
Noah Campbell 74b55fc7c8 Normalize paths within hugo
filepath was used inconsistently throughout the hugolib.  With the
introduction of source and target modules, all path are normalized to
"/".  This simplifies the processing of paths.  It does mean that
contributors need to be aware of using path/filepath in any module other
than source or target is not recommended.  The current exception is
hugolib/config.go
2013-09-12 10:48:59 -07:00
Nelson Silva 998b2f73f8 Added safeHtml template function 2013-09-10 17:19:45 -04:00
Noah Campbell 6274aa0a64 Homepage "/" respects PublishDir
It wasn't taking the value of PublishDir into consideration for the
special case of the homepage "/".

Fixes #75
2013-09-05 09:57:25 -07:00
Noah Campbell 610c06e658 Introduce source.Filesystem
This provides an abstraction over how files are processed by Hugo.  This
allows for alternatives like CMS systems or Dropbox, etc.
2013-09-04 22:42:52 -07:00
Noah Campbell d4d9da9f3a Remove page module dependence on opening files
The site is responsible for reading files, page only operates on
buffers.
2013-09-04 19:36:06 -07:00
Noah Campbell cb00917af6 Expand the ShowPlan functionality 2013-09-03 20:52:50 -07:00
Noah Campbell 4004687fb2 Move to target.Filesystem
Moving the ugly urls logic to the target.  There is still UglyUrl logic
in page for the permlink but this is dealing with the generate of urls.
2013-09-03 20:01:55 -07:00
Noah Campbell 7919603fb5 Add Translate to target
Translate handles Ugly Urls.
2013-09-03 20:00:22 -07:00
Noah Campbell c6ad532b94 Add file reporting to planner 2013-09-03 20:00:22 -07:00
Noah Campbell 13d2c55206 Adding Planner 2013-09-03 20:00:21 -07:00
Noah Campbell 79d9f82e79 Code reorg, helpers.go has been decomposed.
It started with wanting to move templates in template bundles and the
rest followed.  I did my best to start grouping related functions
together, but there are some that I missed.  There is also the method
Urlize that seems to be a special function used in both worlds.  I'll
need to revisit this method.
2013-09-03 16:16:07 -07:00
Noah Campbell 207d8fb7af Date rendering unit tests in pages
Tests to ensure rendering dates in templates is working correctly.
Actually, I was running into invalid templates not giving warnings when
I was trying to render a date.
2013-09-03 14:51:06 -07:00
Noah Campbell 3ecc698f5e Remove hugolib.HTML and hugolib.URL types
These types were not be rendered correctly by the html/template package.
Removing them gets the correct behavior.

Fixes #74
2013-09-03 12:43:56 -07:00
Noah Campbell a591a10626 Include building hugo docs as part of test.
If the building of the doc fails, tarvis will fail.  This will help with
pull requests.
2013-09-03 11:29:43 -07:00
Noah Campbell d841d522f1 Include building hugo docs as part of test.
If the building of the doc fails, tarvis will fail.  This will help with
pull requests.
2013-09-01 20:03:10 -07:00
Fabrizio (Misto) Milo ba82a20321 Add support for amber files
If a layout file ends with .amber it will interpreted as a Amber file

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:32 -07:00
Fabrizio (Misto) Milo ee5865f239 Abstract html/template dependency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:27 -07:00
Fabrizio (Misto) Milo 0a9dc705f3 Use s everywhere for consistency
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 19:51:21 -07:00
Noah Campbell b268e639ba Return an error (other than 0) when ./hugo fails
Being a good OS citizen so folks can compose hugo into their tool chain.
Also helps with git bisect run.
2013-09-01 11:39:32 -07:00
Mark Sanborn 6c8e7edbb4 The <!--more--> (summary divider) now works even if it is on the same line as content
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-09-01 07:44:29 -07:00
Noah Campbell 4349216deb Small code cleanup 2013-08-31 20:00:57 -07:00
Noah Campbell 0fdea0c2c2 Return an error with WritePublic 2013-08-30 21:24:25 -07:00
Noah Campbell 097b782a80 Removing site.Directories.
Please revert if this is used somewhere.
2013-08-30 21:13:50 -07:00
Noah Campbell b14b61af37 Externalize the writing of content to a target
Introducing the target module in hugo.  This provides the simple
interface for writing content given a label (filename) and a io.Reader
containing the content to be written.

If site.Target is not set, it defaults back to the original behavior of
writing to file system.

In hugolib/site_url_test.go I have an InMemoryTarget for testing
purposes and use it to see if the final output of a render matches.
2013-08-30 20:45:42 -07:00
Noah Campbell bc3c229002 Ensure Section is set before returning Page object. 2013-08-30 20:13:22 -07:00
Noah Campbell c32f401b15 Revert "Return errors when rendering"
This reverts commit e66ba5d2a7.

Fixed #69
2013-08-30 20:08:13 -07:00
Noah Campbell a792ec09ce Cleanup formatting - go fmt ./...
Remember to run go fmt ./... before committing.  Looks sternly in mirror
2013-08-30 14:39:12 -07:00
Mark Sanborn 4ed43e8076 Fixed bug where Url specified in front matter as pretty url wouldnt render
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-30 14:39:11 -07:00
Daniel Alan Miller 71678a7183 Adding .Summary to page variables
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-29 10:08:03 -07:00
Fabrizio (Misto) Milo 3ab5245049 clean up logic
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-28 20:39:58 -07:00
Ross Lawley 1bb00b8c19 Refactored added RenderThingOrDefault and tests
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>

Conflicts:
	hugolib/site.go
2013-08-27 12:40:53 -07:00
Noah Campbell 554375b2ad Using new parser. 2013-08-25 20:27:03 -07:00
Hugo Duncan 1de1992664 Return any error reported by RenderHomePage
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-23 16:55:40 -07:00
Ross Lawley 9930011ea2 Wordpress summaries
Allow full control of summaries which can be rendered as html rather
than text.  Using a `<!--more-->` html comment in your markdown / rst
you can indiciate where the summary should end and have the summary
converted to html.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>

Conflicts:
	hugolib/page_test.go
2013-08-23 16:46:19 -07:00
Ross Lawley 7b1f0960e3 Add 404.html for gh-pages
Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
2013-08-23 16:38:35 -07:00
Noah Campbell f28a8fa0c2 RenderThing test cases
Provide unit test support RenderThing.

One observation is that creating the site.Tmpl variable is a one time
event.  site.Tmpl doesn't like additional templates with the same name.
This means that updating a template while in --watch mode requires
throwing away the entire Site object and creating a new one.  Not that
this is a bad idea, but it is something I discovered while working on
these unit tests.
2013-08-23 16:21:28 -07:00
Noah Campbell 9d15262ee5 Test cases for ignoreDotFile
Meant to commit this earlier, but it's a basic unit test.
2013-08-23 14:57:21 -07:00
Noah Campbell 0fabd51ab1 Update .gitignore to ignore *.swo files
For the fellow vim user.
2013-08-23 14:57:21 -07:00
Noah Campbell 7461ed63ae Fix benchmark so the buffer is read each time.
The bytes.Buffer was exhausted after the first read.  Creating a new
reader each invocation catpures the correctly timing.
2013-08-23 14:16:37 -07:00
Noah Campbell 599e6672f7 Removing GetSection
Using GetXXX is not idiomatic to Go.  Also added a bunch of unit testing
around this method.
2013-08-23 14:14:54 -07:00
Noah Campbell ae7112977d Skip "dot" files in layout
As a vim user, .filename.swp files pop up.  This change prevents hugo
from reading those files.
2013-08-23 13:58:52 -07:00
Steve Francia eb4288e3cd Merge pull request #53 from hugoduncan/feature/print-error-on-invalid-index
Print error if index value in a page is wrong type
2013-08-20 20:56:33 -07:00
Steve Francia 00839567c7 Merge pull request #52 from rozza/StaticSync
Static changes shouldn't be destructive to existing files
2013-08-20 20:55:56 -07:00
Steve Francia 35b35a7004 Merge pull request #51 from cabello/patch-3
Remove extra quotes from meta data
2013-08-20 20:54:51 -07:00
Steve Francia 6f424175bf Merge pull request #50 from cabello/patch-2
Check .Prev and .Next pointers before using it
2013-08-20 20:54:31 -07:00
Steve Francia 3d0dc1acb1 Merge pull request #49 from cabello/patch-1
Fix broken link to Index page
2013-08-20 20:54:06 -07:00
Hugo Duncan 301d2bafcd Print error if index value in a page is wrong type
This was causing a panic with no information displayed about the
page causing the error.
2013-08-20 16:39:26 -04:00
Ross Lawley 5aa47a7b07 Static changes shouldn't be destructive to existing files
Currently changing css deletes all the site published html when it copies.
Refs #46
2013-08-20 20:32:32 +01:00
Danilo Cabello 8415c5e6c7 Remove extra quotes from meta data 2013-08-20 13:52:51 -04:00
Danilo Cabello acd5ea0e75 Check .Prev and .Next pointers before using it 2013-08-20 12:13:27 -04:00
Danilo Cabello 8058abd707 Fix broken link to Index page 2013-08-20 11:56:55 -04:00
Steve Francia eff8457ac9 Merge pull request #46 from rawfalafel/sync_static
Sync files that have changed in the static directory
2013-08-19 05:32:36 -07:00
rawfalafel 2dcdd67378 Watch StaticDir and sync to PublishDir on change
New behavior adds a special case for file changes inside the static directory to fsync PublishDir
2013-08-19 01:17:37 -04:00
Steve Francia c4bcdebc59 Merge pull request #44 from cactus/avoid-redirect-with-slugs
avoid possible redirects with non-ugly slug urls
2013-08-17 21:04:51 -07:00
Steve Francia e2744d403c Merge pull request #43 from hugoduncan/feature/allow-xhtml-aliases
Enable aliases from .xhtml paths
2013-08-17 21:04:14 -07:00
Steve Francia 2542836bbc Merge pull request #41 from rozza/skipStatic
Skip Static directory if its in your content directory
2013-08-17 20:59:07 -07:00
spf13 8f330626bc Merge branch 'noahcampbell-index_reporting' 2013-08-17 23:53:35 -04:00
Noah Campbell c713beba4d Formatting cleanup 2013-08-17 23:52:16 -04:00
Noah Campbell ec821739bc Removing the use of slash
An oversight on my behalf.  The FromSlash method is used when writing
out the public file name.  There is one place where the slashes are
required which is setting the output file.  I replaced those instances
with filepath.Join which should do the right thing depending on the OS.
2013-08-17 23:46:57 -04:00
Noah Campbell 8eca8f8aa0 Detect missed index from front matter 2013-08-17 23:45:03 -04:00
Noah Campbell e66ba5d2a7 Return errors when rendering 2013-08-17 23:45:03 -04:00
spf13 0a79edd48a Removing extra links on homepage 2013-08-17 21:54:39 -04:00
spf13 3ae8078d3a Adding "fork me on github" banner 2013-08-17 21:54:39 -04:00
spf13 8c0ab4def1 Complete overhaul of the docs 2013-08-17 21:54:39 -04:00
Steve Francia b76b80c564 Merge pull request #40 from VonC/clarify_uglyurls_flag
Clarify uglyurls flag.
2013-08-17 06:35:31 -07:00
elij b9e835b101 avoid handling a redirect from slug to slug/
because the url lacks a trailing /, many webservers will issue a
redirect to the canonical url with trailing slash for directory index
w/index.htm(l).
Append a slash to avoid this.
2013-08-16 13:14:20 -07:00
Hugo Duncan 23a98ad05c Enable aliases from .xhtml paths
When redirecting an alias from a .xhtml path, served with default content type,
a redirect only works if the html element has a xmlns attribute.  This adds the
attribute when the alias path ends in .xhtml
2013-08-16 00:29:46 -04:00
Ross Lawley 0f143dcf14 Skip Static directory if its in your content directory
Allows organisation where all source files are in one directory:

```
`config.yaml`:

contentdir: "source"
staticdir: "source/static"
...

 .
	└── source
		├── post
		|	├── firstpost.md	// <- http://site.com/post/firstpost.html
		|	└── secondpost.md	// <- http://site.com/post/secondpost.html
		└── static
			└── css
				 └── site.css	// <- http://site.com/css/site.css
```
2013-08-15 20:05:46 +01:00
VonC 9308cd6a7a Clarify uglyurls flag.
Mention more clearly that, for generating `/filename.html`, you need to
set the `uglyurls` flag to `true`.
2013-08-14 16:47:17 +02:00
spf13 3c3fc45d3c Merge branch 'master' of github.com:spf13/hugo 2013-08-14 10:19:59 -04:00
spf13 480e01eb15 Further work on path/section stuff. Tests passing now. 2013-08-14 08:57:14 -04:00
Steve Francia 7a51a8a5a3 Merge pull request #38 from noahcampbell/workflow_dotfile
Workflow dotfile
2013-08-13 20:03:18 -07:00
spf13 b4bcc591e4 Now support for nested paths. Better section detection. 2013-08-13 19:39:24 -04:00
spf13 6e27239485 Merge branch 'master' of github.com:spf13/hugo 2013-08-13 10:47:58 -04:00
Steve Francia ca5a94a988 Merge pull request #37 from noahcampbell/master
Test GetParam and the various incarnations of frontmatter.
2013-08-13 07:44:43 -07:00
Steve Francia c661d9803e Merge pull request #31 from cactus/issue-31
sanitizeRegex chopping dots
2013-08-13 07:44:00 -07:00
spf13 ec02fa4bdd Adding support for a default content type template
default template found at layouts/_default/single.html
2013-08-13 09:23:43 -04:00
spf13 8968524900 Adding support for recent content. 2013-08-13 08:43:42 -04:00
Noah Campbell 97eb9225a7 Ignore dotfiles in content directory
This supports my personal workflow of using vim which places a temporary file in the same directory as the file I'm editing.
2013-08-12 20:40:52 -07:00
Noah Campbell 5664780cca gofmt pass
Clean up test files.
2013-08-12 20:40:34 -07:00
Noah Campbell 2d11d1bd67 Test GetParam and the various incarnations of frontmatter. 2013-08-12 20:25:32 -07:00
elij 31a1ade1b4 move "dot" in regex to avoid it being part of a range 2013-08-12 19:55:52 -07:00
Steve Francia c689d46aa1 Merge pull request #32 from cactus/issue-32
indexes rss.xml has wrong permalinks with ugly urls off
2013-08-12 19:42:44 -07:00
elij b13afc4178 fix sanitizeRegex to not strip "dots"
sanitizeRegex was stripping dots in permalinks when generating
RenderIndexes (noted during feed/rss generation).

permalink was being set to `.../indexxml` instead of `.../index.xml`.

Adding "dot" to the regex whitelist fixed the issue.
2013-08-12 19:02:43 -07:00
elij 023567b05e fix bad tab/space due to paste 2013-08-12 19:01:23 -07:00
elij 2f9b582dbe fix wrong renderlist feed permalink
when not using ugly urls, the feed permalink does not end up in the
expected location, and instead always behaves as if using ugly urls.

this fixes that behavior and inserts the feed xml file into the
directory as index.xml.

fixes #32
2013-08-12 19:00:29 -07:00
Steve Francia cb39f052d1 Merge pull request #36 from noahcampbell/master
Use / for template names regardless of platform.
2013-08-12 15:36:06 -07:00
Noah Campbell 8c03141307 Use / for template names regardless of platform.
The path seperator was causing templates to not be loaded on windows.
Now all template names use / internally.
2013-08-12 15:03:06 -07:00
Steve Francia ec1a3a8db9 Merge pull request #35 from noahcampbell/master
Address the time parsing issue.
2013-08-12 14:43:56 -07:00
Noah Campbell 3fdcd0ba7c Support for non-standard formats.
Forgot to include existing formats.  Integration tests include new
format.
2013-08-12 14:35:39 -07:00
Noah Campbell 0305c82513 Move timezone tests to integration test.
Interacting with timezones will result in checks against the filesystem.
This access, by definition, is an integration test.  Creating a
*integration_test.go file will signify this change.

When interacting with Travis-ci.org, the ubuntu boxes plus go 1.1 do not
seem to support shortcode timezones, think PST.  In this case, the tests
are skipped.  This is not ideal, but the IRC #go-nuts channel has
indicated timezone support is still lacking.  We should advise users of
hugo that timezone support may be an issue and report any odd behavior.
The workaround is to use numeric timezones (-08:00 for PST, etc.)
2013-08-12 12:04:04 -07:00
Noah Campbell f610d45cd8 Add additional details to date test cases. 2013-08-12 09:14:30 -07:00
Noah Campbell dd19d0cc77 Provide better support for various date formats.
Fixes #30 as long as the date is well formatted.
2013-08-12 09:14:29 -07:00
VonC 17aafb39dd Avoid error if no content.
The homepage should still be generated.
This is useful especially in the beginning, where you start just with
the homepage.
2013-08-12 14:31:39 +02:00
Steve Francia 5b3b0f9556 Merge pull request #26 from noahcampbell/master
Add support for continuous testing.
2013-08-11 07:23:08 -07:00
spf13 0233708907 Started new release notes, added nitro step for aliases 2013-08-10 15:44:22 +01:00
spf13 ac26de205e Adding correct canonical link to alias pages 2013-08-10 15:41:10 +01:00
spf13 d5518c0966 Adding support for aliases (redirects) 2013-08-10 15:35:34 +01:00
spf13 45ce6e2b30 Merge branch 'redirect' of https://github.com/rozza/hugo into rozza-redirect
Conflicts:
	hugolib/page.go
2013-08-10 14:08:38 +01:00
Noah Campbell bb273df4cd Add support for continuous testing.
Using travis-ci.org
2013-08-09 18:34:51 -07:00
spf13 733c0207cb Merge branch 'master' of github.com:spf13/hugo
Conflicts:
	hugolib/site.go
2013-08-10 02:07:35 +01:00
Steve Francia 2bf24877a6 Merge pull request #25 from noahcampbell/master
Internal API changes and introduce testing.
2013-08-09 18:01:51 -07:00
Noah Campbell 2bbecc7bc8 Better reporting when the template is missing. 2013-08-09 17:36:32 -07:00
Noah Campbell 309db474c7 Nitro timer is encapsulated.
Remove the need for NewSite by relying on appropriate defaults.  Renamed
site.c to site.Config to allow Sites to be created outside the package.
2013-08-09 17:36:32 -07:00
Noah Campbell e26b43f6d9 Adding more test cases 2013-08-09 17:36:32 -07:00
Noah Campbell e67db666c8 Adding benchmark for parsing pages using unicode.
The resulting comparsion is not equal because NewPage reads the file each time where ReadFrom just reads a buffer in memory.
2013-08-09 17:36:32 -07:00
Noah Campbell 085ce15f7c Adding ability to read from io.Reader
This allows for testing without relying on the file system.  Parsing algorithm to not read the entire file into memory.
2013-08-09 17:36:32 -07:00
Noah Campbell 274d324c8b Introduce unit testing for page.go 2013-08-09 17:36:32 -07:00
Noah Campbell fa55cd9857 Remove unreachable code path. 2013-08-09 17:36:32 -07:00
Noah Campbell 0595f27e6d Using a composite literal to create a page.
Wonder why the need for composite structs.  Not sure if my go knowledge is lacking or if this is cruft from other programming language doctrine.
2013-08-09 17:36:32 -07:00
Noah Campbell 19538a1bd6 Support pages without folders 2013-08-09 17:36:31 -07:00
Noah Campbell fc5e92cc24 Provide better error handling
Change the method signatures to follow the check ok pattern.
2013-08-09 17:36:31 -07:00
Ross Lawley e2a28114d1 Add redirect to page parameters and redirects example 2013-08-09 21:57:22 +01:00
Steve Francia 4f17ad69a7 Merge pull request #22 from nsabine/master
Added examples to indexes.md
2013-08-09 02:16:10 -07:00
Steve Francia 7a13434dd9 Merge pull request #21 from duncanbeevers/master
Added .Content variable to docs
2013-08-09 02:15:50 -07:00
Nick Sabine a8b3e1537f Added examples to indexes.md 2013-08-09 00:10:35 -04:00
Duncan Beevers 04a0dbbf73 Added .Content variable to docs 2013-08-08 16:13:03 -07:00
Steve Francia 6a5e4b363a Merge pull request #20 from VonC/version
Make sure hugo --version prints the version and does *nothing* else.
2013-08-08 15:52:50 -07:00
VonC 49b8ac5fbc Make sure hugo --version prints the version and does *nothing* else.
Any program, when asks to print their version, only prints that, and then
stops.
hugo checks the config (and prints a warning message if not found), and
proceeds to generate the site!
Yet, the user just wanted to check the version.

This patch makes sure hugo stops after printing the version.
2013-08-08 22:21:56 +02:00
spf13 a870f4d955 Fixing missing trailing slash in baseUrl 2013-08-08 12:30:01 +01:00
Steve Francia d89c7ec7a2 Merge pull request #19 from nsabine/master
Populated page Site metadata.  Enables accessing Indexes from Page template.
2013-08-07 14:05:07 -07:00
Nick Sabine 780e2f311b Populated page Site metadata. Enables accessing Indexes from Page template. 2013-08-07 14:23:24 -04:00
Steve Francia 42de9bd8bb Merge pull request #15 from hhatto/update-doc
update document for content directory
2013-08-06 08:05:18 -07:00
spf13 0e57fcc9c2 Merge branch 'master' of github.com:spf13/hugo 2013-08-06 01:10:10 +02:00
spf13 783f0d6154 fixing badlink on homepage 2013-08-06 01:06:59 +02:00
spf13 6789b6c5ce removing erroneous debugging output 2013-08-06 01:05:50 +02:00
Hideo Hattori 78afe8d344 update document for content directory 2013-08-06 03:14:40 +09:00
Steve Francia c5715e9800 Merge pull request #12 from imrehg/docfix
Fix example in docs that wouldn't work in practice
2013-08-05 07:13:42 -07:00
Gergely Imreh f31ec3c280 Fix example in docs that wouldn't work in practice
The pflag package used in hugo has to use the "=" sign
for double dash options such as --source. Thus the original
example `--source ~/mysite` is already incorrect. Adding
the = sign though woul not fix things in this case, since
`--source=~/mysite` does not get resolved to /home/username/mysite,
but looks for the ./~/mysite directory within the current directory.

To resolve this, either the directory name has to be changed in
the docs not to use the "~" sign, or have to change to use the
single dash version of the command line flag. The latter seems
to be more in line with the rest of the example.

Leaving `--watch` as a double dash option to minimize the change,
though it could be either way, since the follow up example uses
the single dash version of both.
2013-08-05 21:45:01 +08:00
spf13 de9f9ae16e Fixing getting started link. 2013-08-05 11:12:39 +02:00
Steve Francia 57b206ca11 Merge pull request #11 from noahcampbell/master
Removing OSX files from repo.  Updating .gitignore to not track these files
2013-08-03 07:29:16 -07:00
spf13 f6e590e536 Fixing link to contributor page on github 2013-08-03 03:33:39 -04:00
spf13 6a1a038c57 Shrinking the readme to just the basics to avoid dupe with doc site 2013-08-03 03:31:25 -04:00
spf13 6efbd93a38 Updating a bunch of the docs 2013-08-03 03:30:34 -04:00
spf13 def5f10183 Including documentation on indexes 2013-08-03 03:29:49 -04:00
spf13 dff86cb22c Renaming indexes template to indexes.html 2013-08-03 03:29:24 -04:00
spf13 21a7b72535 Moved static content to /static 2013-08-03 03:10:14 -04:00
spf13 52c089ffbd Added support for indexes of indexes & ordered indexes 2013-08-03 03:09:28 -04:00
spf13 ddad1e04ac adding previous next capabilities 2013-08-02 16:30:26 -04:00
Noah Campbell 66610a65d1 Removing OSX files from repo. Updating .gitignore to not track these files. 2013-08-02 10:00:25 -07:00
Steve Francia d36d7fba6a Merge pull request #8 from SebastianM/doc-json-fix
Fix JSON syntax error in example configuration
2013-08-01 22:04:03 -07:00
Steve Francia 47783c1f03 Merge pull request #10 from noahcampbell/master
Fixed section labels causing panic on windows.
2013-08-01 22:00:58 -07:00
Noah Campbell 3e539c7126 Adding error message when no content pages exists. 2013-08-01 13:27:56 -07:00
Noah Campbell 03e804ffd2 Updating the .gitignore for windows and vim users.
Adding hugo.exe for us windows fanbois.  Also adding gvim support.
2013-08-01 13:27:56 -07:00
Noah Campbell c9a09418e7 Fixed section labels causing panic on windows.
The filename path was being split using a unix specific path seperator.  This fix uses the os.PathSeperator to ensure proper evaluation regardless of platform.
2013-08-01 13:27:56 -07:00
Sebastian Müller 4efdb90943 Fix JSON syntax error in example configuration 2013-08-01 20:52:00 +02:00
spf13 61258858af copying static content to destination 2013-07-30 01:26:02 -04:00
spf13 736677a21d Using MkdirAll instead of my own logic 2013-07-26 18:10:03 -04:00
spf13 7ab28c564f Adding support for destination dir, split out static 2013-07-26 18:06:13 -04:00
spf13 92c31bbe10 permalink now respects pretty urls 2013-07-26 09:56:00 -04:00
spf13 d5f5543061 create content at any level of nesting 2013-07-26 09:28:26 -04:00
spf13 e08d14ad49 fixing issue with some urls missing '/' 2013-07-26 09:27:22 -04:00
spf13 b7bbc28caf fixing bug with server not finding right path 2013-07-26 09:25:30 -04:00
spf13 c560a7537a adding more verbose output to server functionality 2013-07-26 09:24:35 -04:00
spf13 b2385f062a create missing directories recurisvely 2013-07-26 09:22:23 -04:00
spf13 dd9a7e6455 Fixing headers in readme 2013-07-24 11:47:58 -04:00
spf13 16b1f284ca Improving installation instructions 2013-07-24 11:43:23 -04:00
spf13 f2e4c9d709 Merge branch 'master' of github.com:spf13/hugo 2013-07-24 11:27:48 -04:00
spf13 3ad3f2f0e0 Merge branch 'doc-fix' of https://github.com/brandonblack/hugo into brandonblack-doc-fix
Conflicts:
	README.md
2013-07-24 11:27:03 -04:00
Brandon Black 580bb9bb5b minor: adding some more instructions for building from source 2013-07-22 14:40:45 -07:00
Steve Francia 2dde27f0dc Update README.md
fixing typo in readme.
2013-07-21 00:51:39 -04:00
spf13 627cf26571 Adding proper command line option parsing 2013-07-19 00:38:24 -07:00
spf13 8fae5f0dd6 Default is now pretty urls (without .html)
Adding --uglyurls option to retain previous behavior
2013-07-19 00:10:42 -07:00
spf13 dcd8ff716a Adding better source build instructions 2013-07-18 22:30:55 -07:00
spf13 f199004989 GO -> Go 2013-07-15 17:44:51 -07:00
spf13 8d50dd9160 fixing typo in config readme 2013-07-11 23:29:14 -04:00
spf13 c24112ce86 Render shortcodes before index and section rss feeds 2013-07-11 23:26:03 -04:00
spf13 649560fca2 proper BaseUrl handling (if has trailing slash or not) 2013-07-11 22:55:07 -04:00
spf13 7a521ad1a1 Fixing some RSS issues 2013-07-11 22:31:58 -04:00
spf13 b7b6f054a9 Accidentally left in debugging code 2013-07-11 22:16:29 -04:00
spf13 75a2e6d4e8 Now support for config files as yaml, json or toml 2013-07-11 22:04:57 -04:00
spf13 d9b5f9cd9e fixing incorrect import path 2013-07-10 17:58:32 -04:00
spf13 f857f4caba adding helper to create absolute url 2013-07-10 17:57:28 -04:00
spf13 d4caa8ee95 Adding total time to generated stats. 2013-07-10 09:21:41 -04:00
spf13 51e3098548 Writing relative links to absolute so they work in feeds 2013-07-10 00:14:02 -04:00
spf13 e76c3feb52 Fix bug with JSON front matter parsing. 2013-07-09 19:04:22 -04:00
spf13 a6914e9c4c Better error handling for parsing front matter 2013-07-09 18:53:08 -04:00
Steve Francia 8403dba3ee Merge pull request #3 from tychoish/rst-fix
rst: fixing rst output processing
2013-07-09 08:34:20 -07:00
tycho garen 4951ff998c rst: fixing rst output processing 2013-07-09 08:16:29 -04:00
spf13 aee48725eb Adding version number to command line options 2013-07-08 22:27:23 -04:00
spf13 d2a6267ad7 Adding support for TOML, updating documentation 2013-07-08 22:23:54 -04:00
spf13 3c80cd323c YAML support similar to jekyll (start and end with '---') 2013-07-08 17:57:01 -04:00
Steve Francia 94e577740d Merge pull request #2 from tychoish/yaml-rst-support
Switching to YAML and adding support for optional restructured text parsing
2013-07-08 12:59:44 -07:00
tycho garen d0ff31269a minor: correcting example 2013-07-07 11:59:19 -04:00
tycho garen f851c4162b fix: changing terminal yaml line, generalizing forematter splitting 2013-07-07 10:01:53 -04:00
tycho garen b024454ea9 fixes: returning json parsing, error messages, yaml header offsets 2013-07-07 01:03:12 -04:00
tycho garen 67f4da30b1 revert: adding json support 2013-07-06 23:52:14 -04:00
tycho garen 6c42d3d490 fix: parsing of yaml forematter 2013-07-06 23:37:47 -04:00
tycho garen 431fa0e2d7 changing to suport yaml rather than json and adding optional restructuredtext support 2013-07-06 22:48:12 -04:00
tycho garen a7f5f97bc2 sanity: move from json to yaml 2013-07-06 22:32:50 -04:00
Steve Francia 4d2fbfc760 Merge pull request #1 from tychoish/add-gitignore
gitignore: sanity
2013-07-06 19:08:40 -07:00
tycho garen 8aff6cc373 gitignore: sanity 2013-07-06 19:37:40 -04:00
spf13 f875577197 rendering shortcodes earlier for better performance 2013-07-05 12:03:47 -04:00
Steve Francia 77d142ba17 fixing typos 2013-07-05 00:37:59 -04:00
Steve Francia 1aa125cf68 fixing two typos 2013-07-05 00:37:26 -04:00
Steve Francia 0d63bf00c3 better install instructions and fixing usage typo 2013-07-05 00:35:11 -04:00
364 changed files with 42244 additions and 3266 deletions
+7
View File
@@ -0,0 +1,7 @@
hugo
docs/public*
hugo.exe
*.swp
*.swo
.DS_Store
*~
+11
View File
@@ -0,0 +1,11 @@
language: go
go:
- 1.2
- tip
script:
- go test ./...
- go build
- ./hugo -s docs/
install:
- go get github.com/stretchr/testify
- go get -v ./...
+70 -407
View File
@@ -1,438 +1,101 @@
# Hugo
A Fast and Flexible Static Site Generator built with love by [spf13](http://spf13.com)
and [friends](http://github.com/spf13/hugo/graphs/contributors) in Go.
A really fast static site generator written in GoLang.
[![Build Status](https://travis-ci.org/spf13/hugo.png)](https://travis-ci.org/spf13/hugo)
[![wercker status](https://app.wercker.com/status/1a0de7d703ce3b80527f00f675e1eb32 "wercker status")](https://app.wercker.com/project/bykey/1a0de7d703ce3b80527f00f675e1eb32)
## Overview
Hugo is a static site generator written in GoLang. It is optimized for
Hugo is a static site generator written in Go. It is optimized for
speed, easy use and configurability. Hugo takes a directory with content and
templates and renders them into a full html website.
Hugo makes use of markdown files with front matter for meta data.
Hugo makes use of markdown files with front matter for meta data.
A typical website of moderate size can be
rendered in a fraction of a second. It is written to work well with any
kind of website including blogs, tumbles and docs.
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 is written to work well with any
kind of website including blogs, tumbles and docs.
**Complete documentation is available at [Hugo Documentation](http://hugo.spf13.com).**
# Getting Started
## Installing Hugo
Installation is very easy. Simply download the appropriate version for your
platform. Hugo is written in GoLang with support for Windows, Linux and OSX.
Hugo is written in Go with support for Windows, Linux, FreeBSD and OSX.
Please make sure that you place the executable in your path. `/usr/local/bin`
The latest release can be found at [hugo releases](https://github.com/spf13/hugo/releases).
We currently build for Windows, Linux, FreeBSD and OS X for x64
and 386 architectures.
### Installing Hugo (binary)
Installation is very easy. Simply download the appropriate version for your
platform from [hugo releases](https://github.com/spf13/hugo/releases).
Once downloaded it can be run from anywhere. You don't need to install
it into a global location. This works well for shared hosts and other systems
where you don't have a privileged account.
Ideally you should install it somewhere in your path for easy use. `/usr/local/bin`
is the most probable location.
Hugo doesn't have any external dependencies, but can benefit from external
programs.
*The Hugo executable has no external dependencies.*
## Installing from source
### Installing from source
Make sure you have a recent version of go installed. Hugo requires go 1.1+.
#### Dependencies
* Git
* Go 1.1+
* Mercurial
* Bazaar
#### Clone locally (for contributors):
git clone https://github.com/spf13/hugo
cd hugo
go get
Because go expects all of your libraries to be found in either $GOROOT or $GOPATH,
it's helpful to symlink the project to one of the following paths:
* ln -s /path/to/your/hugo $GOPATH/src/github.com/spf13/hugo
* ln -s /path/to/your/hugo $GOROOT/src/pkg/github.com/spf13/hugo
#### Get directly from Github:
If you only want to build from source, it's even easier.
go get github.com/spf13/hugo
#### Building Hugo
cd /path/to/hugo
go build -o hugo main.go
mv hugo /usr/local/bin/
#### Running Hugo
## Source Directory Organization
cd /path/to/hugo
go install github.com/spf13/hugo/hugolib
go run main.go
Hugo takes a single directory and uses it as the input for creating a complete website.
#### Contribution Guidelines
Hugo has a very small amount of configuration, while remaining highly customizable.
It accomplishes by assuming that you will only provide templates with the intent of
using them.
We welcome your contributions. To make the process as seamless as possible, we ask for the following:
An example directory may look like:
* Go ahead and fork the project and make your changes. We encourage pull requests to discuss code changes.
* When you're ready to create a pull request, be sure to:
* Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
* Run `go fmt`
* Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request.
* Make sure `go test ./...` passes, and go build completes. Our Travis CI loop will catch most things that are missing. The exception: Windows. We run on windows from time to time, but if you have access please check on a Windows machine too.
.
├── config.json
├── content
| ├── post
| | ├── firstpost.md
| | └── secondpost.md
| └── quote
| | ├── first.md
| | └── second.md
├── layouts
| ├── chrome
| | ├── header.html
| | └── footer.html
| ├── indexes
| | ├── category.html
| | ├── post.html
| | ├── quote.html
| | └── tag.html
| ├── post
| | ├── li.html
| | ├── single.html
| | └── summary.html
| ├── quote
| | ├── li.html
| | ├── single.html
| | └── summary.html
| ├── shortcodes
| | ├── img.html
| | ├── vimeo.html
| | └── youtube.html
| ├── index.html
| └── rss.xml
└── public
**Complete documentation is available at [Hugo Documentation](http://hugo.spf13.com).**
This directory structure tells us a lot about this site:
1. the website intends to have two different types of content, posts and quotes.
2. It will also apply two different indexes to that content, categories and tags.
3. It will be displaying content in 3 different views, a list, a summary and a full page view.
Included with the repository is an example site ready to be rendered.
## Configuration
The directory structure and templates provide the majority of the
configuration for a site. In fact a config file isn't even needed for many websites
since the defaults used follow commonly used patterns.
The following is an example of a config file with the default values
{
"SourceDir" : "content",
"LayoutDir" : "layouts",
"PublishDir" : "public",
"BuildDrafts" : false,
"Tags" : { "category" : "categories", "tag" : "tags" },
"BaseUrl" : "http://yourSite.com/"
}
## Usage
Make sure either hugo is in your path or provide a path to it.
$ hugo --help
usage: hugo [flags] []
-b="": hostname (and path) to the root eg. http://spf13.com/
-c="config.json": config file (default is path/config.json)
-d=false: include content marked as draft
-h=false: show this help
-k=false: analyze content and provide feedback
-p="": filesystem path to read files relative from
-w=false: watch filesystem for changes and recreate as needed
-s=false: a (very) simple webserver
-p="1313": port for webserver to run on
The most common use is probably to run hugo with your current
directory being the input directory.
$ hugo
> X pages created
> Y indicies created
If you are working on things and want to see the changes
immediately, tell Hugo to watch for changes. **It will
recreate the site faster than you can tab over to
your browser to view the changes.**
$ hugo -p ~/mysite -w
# Layout
Hugo is very flexible about how you organize and structure your content.
## Templates
Hugo uses the excellent golang html/template library for it's template engine. It is an extremely
lightweight engine that provides a very small amount of logic. In our
experience that it is just the right amount of logic to be able to create a good static website
This document will not cover how to use golang templates, but the [golang docs](http://golang.org/pkg/html/template/)
provide a good introduction.
### Template roles
There are 5 different kinds of templates that Hugo works with.
#### index.html
This file must exist in the layouts directory. It is the template used to render the
homepage of your site.
#### rss.xml
This file must exist in the layouts directory. It will be used to render all rss documents.
The one provided in the example application will generate an ATOM format.
*Important: Hugo will automatically add the following header line to this file.*
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
#### Indexes
An index is a page that list multiple pieces of content. If you think of a typical blog, the tag
pages are good examples of indexes.
#### Content Type(s)
Hugo supports multiple types of content. Another way of looking at this is that Hugo has the ability
to render content in a variety of ways as determined by the type.
#### Chrome
Chrome is simply the decoration of your site. It's not a requirement to have this, but in practice
it's very convenient. Hugo doesn't know anything about Chrome, it's simply a convention that you may
likely find beneficial. As you create the rest of your templates you will include templates from the
/layout/chrome directory. I've found it helpful to include a header and footer template
in Chrome so I can include those in the other full page layouts (index.html, indexes/ type/single.html).
### Adding a new content type
Adding a type is easy.
**Step 1:**
Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*.
**Step 2:**
Create a file called single.html inside your directory. *Eg /layouts/post/single.html*.
**Step 3:**
Create a file with the same name as your directory in /layouts/indexes/. *Eg /layouts/index/post.html*.
**Step 4:**
Many sites support rendering content in a few different ways, for instance a single page view and a
summary view to be used when displaying a list of contents on a single page. Hugo makes no assumptions
here about how you want to display your content, and will support as many different views of a content
type as your site requires. All that is required for these additional views is that a template
exists in each layout/type directory with the same name.
For these, reviewing the example site will be very helpful in order to understand how these types work.
## Variables
Hugo makes a set of values available to the templates. Go templates are context based. The following
are available in the context for the templates.
**.Title** The title for the content. <br>
**.Description** The description for the content.<br>
**.Keywords** The meta keywords for this content.<br>
**.Date** The date the content is published on.<br>
**.Indexes** These will use the field name of the plural form of the index (see tags and categories above)<br>
**.Permalink** The Permanent link for this page.<br>
**.FuzzyWordCount** The approximate number of words in the content.<br>
**.RSSLink** Link to the indexes' rss link <br>
Any value defined in the front matter, including indexes will be made available under `.Params`.
Take for example I'm using tags and categories as my indexes. The following would be how I would access them:
**.Params.Tags** <br>
**.Params.Categories** <br>
Also available is `.Site` which has the following:
**.Site.BaseUrl** The base URL for the site as defined in the config.json file.<br>
**.Site.Indexes** The names of the indexes of the site.<br>
**.Site.LastChange** The date of the last change of the most recent content.<br>
**.Site.Recent** Array of all content ordered by Date, newest first<br>
# Content
Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization
that you provide for your content to minimize any extra configuration, though this can be overridden
by additional configuration in the front matter.
## Organization
In Hugo the content should be arranged in the same way they are intended for the rendered website.
Without any additional configuration the following will just work.
.
└── content
├── post
| ├── firstpost.md // <- http://site.com/post/firstpost.html
| └── secondpost.md // <- http://site.com/post/secondpost.html
└── quote
├── first.md // <- http://site.com/quote/first.html
└── second.md // <- http://site.com/quote/second.html
## Front Matter
The front matter is one of the features that gives Hugo it's strength. It enables
you to include the meta data of the content right with it. Hugo supports a few
different formats. The main format supported is JSON. Here is an example:
{
"Title": "spf13-vim 3.0 release and new website",
"Description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"Tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
"Pubdate": "2012-04-06",
"Categories": [ "Development", "VIM" ],
"Slug": "spf13-vim-3-0-release-and-new-website"
}
### Variables
There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want to. These will be placed into the `.Params` variable available to the templates.
#### Required
**Title** The title for the content. <br>
**Description** The description for the content.<br>
**Pubdate** The date the content will be sorted by.<br>
**Indexes** These will use the field name of the plural form of the index (see tags and categories above)
#### Optional
**Draft** If true the content will not be rendered unless `hugo` is called with -d<br>
**Type** The type of the content (will be derived from the directory automatically if unset).<br>
**Slug** The token to appear in the tail of the url.<br>
*or*<br>
**Url** The full path to the content from the web root.<br>
*If neither is present the filename will be used.*
## Example
Somethings are better shown than explained. The following is a very basic example of a content file:
**mysite/project/nitro.md <- http://mysite.com/project/nitro.html**
{
"Title": "Nitro : A quick and simple profiler for golang",
"Description": "",
"Keywords": [ "Development", "golang", "profiling" ],
"Tags": [ "Development", "golang", "profiling" ],
"Pubdate": "2013-06-19",
"Topics": [ "Development", "GoLang" ],
"Slug": "nitro",
"project_url": "http://github.com/spf13/nitro"
}
# Nitro
Quick and easy performance analyzer library for golang.
## Overview
Nitro is a quick and easy performance analyzer library for golang.
It is useful for comparing A/B against different drafts of functions
or different functions.
## Implementing Nitro
Using Nitro is simple. First use go get to install the latest version
of the library.
$ go get github.com/spf13/nitro
Next include nitro in your application.
# Extras
## Shortcodes
Because Hugo uses markdown for it's content format, it was clear that there's a lot of things that
markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it.
However we cannot accept being constrained by our simple format. Also unacceptable is writing raw
html in our markdown every time we want to include unsupported content such as a video. To do
so is in complete opposition to the intent of using a bare bones format for our content and
utilizing templates to apply styling for display.
To avoid both of these limitations Hugo has full support for shortcodes.
### What is a shortcode?
A shortcode is a simple snippet inside a markdown file that Hugo will render using a template.
Short codes are designated by the opening and closing characters of '{{%' and '%}}' respectively.
Short codes are space delimited. The first word is always the name of the shortcode. Following the
name are the parameters. The author of the shortcode can choose if the short code
will use positional parameters or named parameters (but not both). A good rule of thumb is that if a
short code has a single required value in the case of the youtube example below then positional
works very well. For more complex layouts with optional parameters named parameters work best.
The format for named parameters models that of html with the format name="value"
### Example: youtube
{{% youtube 09jf3ow9jfw %}}
This would be rendered as
<div class="embed video-player">
<iframe class="youtube-player" type="text/html"
width="640" height="385"
src="http://www.youtube.com/embed/09jf3ow9jfw"
allowfullscreen frameborder="0">
</iframe>
</div>
### Example: image with caption
{{% img src="/media/spf13.jpg" title="Steve Francia" %}}
Would be rendered as:
<figure >
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
### Creating a shortcode
All that you need to do to create a shortcode is place a template in the layouts/shortcodes directory.
The template name will be the name of the shortcode.
**Inside the template**
To access a parameter by either position or name the index method can be used.
{{ index .Params 0 }}
or
{{ index .Params "class" }}
To check if a parameter has been provided use the isset method provided by Hugo.
{{ if isset .Params "class"}} class="{{ index .Params "class"}}" {{ end }}
# Meta
## Release Notes
* **0.7.0** July 4, 2013
* Hugo now includes a simple server
* First public release
* **0.6.0** July 2, 2013
* Hugo includes an example documentation site which it builds
* **0.5.0** June 25, 2013
* Hugo is quite usable and able to build spf13.com
## Roadmap
In no particular order, here is what I'm working on:
* Pagination
* Support for top level pages (other than homepage)
* Series support
* Syntax highlighting
* Previous & Next
* Related Posts
* Support for TOML front matter
* Proper YAML support for front matter
* Support for other formats
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Contributors
* [spf13](https://github.com/spf13)
## License
Hugo is released under the Simple Public License. See [LICENSE.md](https://github.com/spf13/hugo/blob/master/LICENSE.md).
[![Analytics](https://ga-beacon.appspot.com/UA-7131036-6/hugo/readme)](https://github.com/igrigorik/ga-beacon)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/spf13/hugo/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
+3
View File
@@ -0,0 +1,3 @@
PASS
BenchmarkChain 500000 7074 ns/op 3913 B/op 15 allocs/op
ok github.com/spf13/hugo/transform 3.669s
+54
View File
@@ -0,0 +1,54 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"github.com/spf13/cobra"
"os"
"runtime/pprof"
)
var cpuProfilefile string
var benchmarkTimes int
var benchmark = &cobra.Command{
Use: "benchmark",
Short: "Benchmark hugo by building a site a number of times",
Long: `Hugo can build a site many times over and anlyze the
running process creating a `,
Run: func(cmd *cobra.Command, args []string) {
InitializeConfig()
bench(cmd, args)
},
}
func init() {
benchmark.Flags().StringVar(&cpuProfilefile, "outputfile", "/tmp/hugo-cpuprofile", "path/filename for the profile file")
benchmark.Flags().IntVarP(&benchmarkTimes, "count", "n", 13, "number of times to build the site")
}
func bench(cmd *cobra.Command, args []string) {
f, err := os.Create(cpuProfilefile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
for i := 0; i < benchmarkTimes; i++ {
_ = buildSite()
}
}
+31
View File
@@ -0,0 +1,31 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"github.com/spf13/cobra"
"github.com/spf13/hugo/hugolib"
)
var check = &cobra.Command{
Use: "check",
Short: "Check content in the source directory",
Long: `Hugo will perform some basic analysis on the
content provided and will give feedback.`,
Run: func(cmd *cobra.Command, args []string) {
InitializeConfig()
site := hugolib.Site{}
site.Analyze()
},
}
+146
View File
@@ -0,0 +1,146 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"fmt"
"path"
"time"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
)
var OutputDir string
var Unsafe bool
var convertCmd = &cobra.Command{
Use: "convert",
Short: "Convert will modify your content to different formats",
Long: `Convert will modify your content to different formats`,
Run: nil,
}
var toJSONCmd = &cobra.Command{
Use: "toJSON",
Short: "Convert front matter to JSON",
Long: `toJSON will convert all front matter in the content
directory to use JSON for the front matter`,
Run: func(cmd *cobra.Command, args []string) {
err := convertContents(rune([]byte(parser.JSON_LEAD)[0]))
if err != nil {
jww.ERROR.Println(err)
}
},
}
var toTOMLCmd = &cobra.Command{
Use: "toTOML",
Short: "Convert front matter to TOML",
Long: `toTOML will convert all front matter in the content
directory to use TOML for the front matter`,
Run: func(cmd *cobra.Command, args []string) {
err := convertContents(rune([]byte(parser.TOML_LEAD)[0]))
if err != nil {
jww.ERROR.Println(err)
}
},
}
var toYAMLCmd = &cobra.Command{
Use: "toYAML",
Short: "Convert front matter to YAML",
Long: `toYAML will convert all front matter in the content
directory to use YAML for the front matter`,
Run: func(cmd *cobra.Command, args []string) {
err := convertContents(rune([]byte(parser.YAML_LEAD)[0]))
if err != nil {
jww.ERROR.Println(err)
}
},
}
func init() {
convertCmd.AddCommand(toJSONCmd)
convertCmd.AddCommand(toTOMLCmd)
convertCmd.AddCommand(toYAMLCmd)
convertCmd.PersistentFlags().StringVarP(&OutputDir, "output", "o", "", "filesystem path to write files to")
convertCmd.PersistentFlags().BoolVar(&Unsafe, "unsafe", false, "enable less safe operations, please backup first")
}
func convertContents(mark rune) (err error) {
InitializeConfig()
site := &hugolib.Site{}
if err := site.Initialise(); err != nil {
return err
}
if site.Source == nil {
panic(fmt.Sprintf("site.Source not set"))
}
if len(site.Source.Files()) < 1 {
return fmt.Errorf("No source files found")
}
jww.FEEDBACK.Println("processing", len(site.Source.Files()), "content files")
for _, file := range site.Source.Files() {
jww.INFO.Println("Attempting to convert", file.LogicalName)
page, err := hugolib.NewPage(file.LogicalName)
if err != nil {
return err
}
psr, err := parser.ReadFrom(file.Contents)
if err != nil {
jww.ERROR.Println("Error processing file:", path.Join(file.Dir, file.LogicalName))
return err
}
metadata, err := psr.Metadata()
if err != nil {
jww.ERROR.Println("Error processing file:", path.Join(file.Dir, file.LogicalName))
return err
}
// better handling of dates in formats that don't have support for them
if mark == parser.FormatToLeadRune("json") || mark == parser.FormatToLeadRune("yaml") || mark == parser.FormatToLeadRune("toml") {
newmetadata := cast.ToStringMap(metadata)
for k, v := range newmetadata {
switch vv := v.(type) {
case time.Time:
newmetadata[k] = vv.Format(time.RFC3339)
}
}
metadata = newmetadata
}
page.Dir = file.Dir
page.SetSourceContent(psr.Content())
page.SetSourceMetaData(metadata, mark)
if OutputDir != "" {
page.SaveSourceAs(path.Join(OutputDir, page.FullFilePath()))
} else {
if Unsafe {
page.SaveSource()
} else {
jww.FEEDBACK.Println("Unsafe operation not allowed, use --unsafe or set a different output path")
}
}
}
return
}
+378
View File
@@ -0,0 +1,378 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"fmt"
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
"github.com/mostafah/fsync"
"github.com/spf13/cobra"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/livereload"
"github.com/spf13/hugo/utils"
"github.com/spf13/hugo/watcher"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/nitro"
"github.com/spf13/viper"
)
//var Config *hugolib.Config
var HugoCmd = &cobra.Command{
Use: "hugo",
Short: "Hugo is a very fast static site generator",
Long: `A Fast and Flexible Static Site Generator built with
love by spf13 and friends in Go.
Complete documentation is available at http://hugo.spf13.com`,
Run: func(cmd *cobra.Command, args []string) {
InitializeConfig()
build()
},
}
var hugoCmdV *cobra.Command
var BuildWatch, Draft, Future, UglyUrls, Verbose, Logging, VerboseLog, DisableRSS, DisableSitemap, PluralizeListTitles bool
var Source, Destination, Theme, BaseUrl, CfgFile, LogFile string
func Execute() {
AddCommands()
utils.StopOnErr(HugoCmd.Execute())
}
func AddCommands() {
HugoCmd.AddCommand(serverCmd)
HugoCmd.AddCommand(version)
HugoCmd.AddCommand(check)
HugoCmd.AddCommand(benchmark)
HugoCmd.AddCommand(convertCmd)
HugoCmd.AddCommand(newCmd)
}
func init() {
HugoCmd.PersistentFlags().BoolVarP(&Draft, "buildDrafts", "D", false, "include content marked as draft")
HugoCmd.PersistentFlags().BoolVarP(&Future, "buildFuture", "F", false, "include content with datePublished in the future")
HugoCmd.PersistentFlags().BoolVar(&DisableRSS, "disableRSS", false, "Do not build RSS files")
HugoCmd.PersistentFlags().BoolVar(&DisableSitemap, "disableSitemap", false, "Do not build Sitemap file")
HugoCmd.PersistentFlags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
HugoCmd.PersistentFlags().StringVarP(&Destination, "destination", "d", "", "filesystem path to write files to")
HugoCmd.PersistentFlags().StringVarP(&Theme, "theme", "t", "", "theme to use (located in /themes/THEMENAME/)")
HugoCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
HugoCmd.PersistentFlags().BoolVar(&UglyUrls, "uglyUrls", false, "if true, use /filename.html instead of /filename/")
HugoCmd.PersistentFlags().StringVarP(&BaseUrl, "baseUrl", "b", "", "hostname (and path) to the root eg. http://spf13.com/")
HugoCmd.PersistentFlags().StringVar(&CfgFile, "config", "", "config file (default is path/config.yaml|json|toml)")
HugoCmd.PersistentFlags().BoolVar(&Logging, "log", false, "Enable Logging")
HugoCmd.PersistentFlags().StringVar(&LogFile, "logFile", "", "Log File path (if set, logging enabled automatically)")
HugoCmd.PersistentFlags().BoolVar(&VerboseLog, "verboseLog", false, "verbose logging")
HugoCmd.PersistentFlags().BoolVar(&nitro.AnalysisOn, "stepAnalysis", false, "display memory and timing of different steps of the program")
HugoCmd.PersistentFlags().BoolVar(&PluralizeListTitles, "pluralizeListTitles", true, "Pluralize titles in lists using inflect")
HugoCmd.Flags().BoolVarP(&BuildWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed")
hugoCmdV = HugoCmd
}
func InitializeConfig() {
viper.SetConfigFile(CfgFile)
viper.AddConfigPath(Source)
err := viper.ReadInConfig()
if err != nil {
jww.ERROR.Println("Config not found... using only defaults, stuff may not work")
}
viper.RegisterAlias("taxonomies", "indexes")
viper.SetDefault("Watch", false)
viper.SetDefault("MetaDataFormat", "toml")
viper.SetDefault("DisableRSS", false)
viper.SetDefault("DisableSitemap", false)
viper.SetDefault("ContentDir", "content")
viper.SetDefault("LayoutDir", "layouts")
viper.SetDefault("StaticDir", "static")
viper.SetDefault("ArchetypeDir", "archetypes")
viper.SetDefault("PublishDir", "public")
viper.SetDefault("DefaultLayout", "post")
viper.SetDefault("BuildDrafts", false)
viper.SetDefault("BuildFuture", false)
viper.SetDefault("UglyUrls", false)
viper.SetDefault("Verbose", false)
viper.SetDefault("CanonifyUrls", false)
viper.SetDefault("Indexes", map[string]string{"tag": "tags", "category": "categories"})
viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0))
viper.SetDefault("Sitemap", hugolib.Sitemap{Priority: -1})
viper.SetDefault("PygmentsStyle", "monokai")
viper.SetDefault("PygmentsUseClasses", false)
viper.SetDefault("DisableLiveReload", false)
viper.SetDefault("PluralizeListTitles", true)
if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed {
viper.Set("BuildDrafts", Draft)
}
if hugoCmdV.PersistentFlags().Lookup("buildFuture").Changed {
viper.Set("BuildFuture", Future)
}
if hugoCmdV.PersistentFlags().Lookup("uglyUrls").Changed {
viper.Set("UglyUrls", UglyUrls)
}
if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed {
viper.Set("DisableRSS", DisableRSS)
}
if hugoCmdV.PersistentFlags().Lookup("disableSitemap").Changed {
viper.Set("DisableSitemap", DisableSitemap)
}
if hugoCmdV.PersistentFlags().Lookup("verbose").Changed {
viper.Set("Verbose", Verbose)
}
if hugoCmdV.PersistentFlags().Lookup("pluralizeListTitles").Changed {
viper.Set("PluralizeListTitles", PluralizeListTitles)
}
if hugoCmdV.PersistentFlags().Lookup("logFile").Changed {
viper.Set("LogFile", LogFile)
}
if BaseUrl != "" {
if !strings.HasSuffix(BaseUrl, "/") {
BaseUrl = BaseUrl + "/"
}
viper.Set("BaseUrl", BaseUrl)
}
if Theme != "" {
viper.Set("theme", Theme)
}
if Destination != "" {
viper.Set("PublishDir", Destination)
}
if Source != "" {
viper.Set("WorkingDir", Source)
} else {
dir, _ := helpers.FindCWD()
viper.Set("WorkingDir", dir)
}
if VerboseLog || Logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
jww.SetLogFile(viper.GetString("LogFile"))
} else {
jww.UseTempLogFile("hugo")
}
} else {
jww.DiscardLogging()
}
if viper.GetBool("verbose") {
jww.SetStdoutThreshold(jww.LevelInfo)
}
if VerboseLog {
jww.SetLogThreshold(jww.LevelInfo)
}
jww.INFO.Println("Using config file:", viper.ConfigFileUsed())
}
func build(watches ...bool) {
utils.CheckErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))
watch := false
if len(watches) > 0 && watches[0] {
watch = true
}
utils.StopOnErr(buildSite(BuildWatch || watch))
if BuildWatch {
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("ContentDir")))
jww.FEEDBACK.Println("Press ctrl+c to stop")
utils.CheckErr(NewWatcher(0))
}
}
func copyStatic() error {
staticDir := helpers.AbsPathify(viper.GetString("StaticDir")) + "/"
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
jww.ERROR.Println("Unable to find Static Directory:", viper.GetString("theme"), "in", staticDir)
return nil
}
publishDir := helpers.AbsPathify(viper.GetString("PublishDir")) + "/"
if themeSet() {
themeDir := helpers.AbsPathify("themes/"+viper.GetString("theme")) + "/static/"
if _, err := os.Stat(themeDir); os.IsNotExist(err) {
jww.ERROR.Println("Unable to find static directory for theme :", viper.GetString("theme"), "in", themeDir)
return nil
}
// Copy Static to Destination
jww.INFO.Println("syncing from", themeDir, "to", publishDir)
fsync.Sync(publishDir, themeDir)
}
// Copy Static to Destination
jww.INFO.Println("syncing from", staticDir, "to", publishDir)
return fsync.Sync(publishDir, staticDir)
}
func getDirList() []string {
var a []string
walker := func(path string, fi os.FileInfo, err error) error {
if err != nil {
jww.ERROR.Println("Walker: ", err)
return nil
}
if fi.IsDir() {
a = append(a, path)
}
return nil
}
filepath.Walk(helpers.AbsPathify(viper.GetString("ContentDir")), walker)
filepath.Walk(helpers.AbsPathify(viper.GetString("LayoutDir")), walker)
filepath.Walk(helpers.AbsPathify(viper.GetString("StaticDir")), walker)
if themeSet() {
filepath.Walk(helpers.AbsPathify("themes/"+viper.GetString("theme")), walker)
}
return a
}
func themeSet() bool {
return viper.GetString("theme") != ""
}
func buildSite(watching ...bool) (err error) {
startTime := time.Now()
site := &hugolib.Site{}
if len(watching) > 0 && watching[0] {
site.RunMode.Watching = true
}
err = site.Build()
if err != nil {
return err
}
site.Stats()
jww.FEEDBACK.Printf("in %v ms\n", int(1000*time.Since(startTime).Seconds()))
return nil
}
func NewWatcher(port int) error {
if runtime.GOOS == "darwin" {
tweakLimit()
}
watcher, err := watcher.New(1 * time.Second)
var wg sync.WaitGroup
if err != nil {
fmt.Println(err)
return err
}
defer watcher.Close()
wg.Add(1)
for _, d := range getDirList() {
if d != "" {
_ = watcher.Watch(d)
}
}
go func() {
for {
select {
case evs := <-watcher.Event:
jww.INFO.Println("File System Event:", evs)
static_changed := false
dynamic_changed := false
for _, ev := range evs {
ext := filepath.Ext(ev.Name)
istemp := strings.HasSuffix(ext, "~") || (ext == ".swp") || (ext == ".tmp")
if istemp {
continue
}
// renames are always followed with Create/Modify
if ev.IsRename() {
continue
}
isstatic := strings.HasPrefix(ev.Name, helpers.AbsPathify(viper.GetString("StaticDir"))) || strings.HasPrefix(ev.Name, helpers.AbsPathify("themes/"+viper.GetString("theme"))+"/static/")
static_changed = static_changed || isstatic
dynamic_changed = dynamic_changed || !isstatic
// add new directory to watch list
if s, err := os.Stat(ev.Name); err == nil && s.Mode().IsDir() {
if ev.IsCreate() {
watcher.Watch(ev.Name)
}
}
}
if static_changed {
fmt.Print("Static file changed, syncing\n\n")
utils.StopOnErr(copyStatic(), fmt.Sprintf("Error copying static files to %s", helpers.AbsPathify(viper.GetString("PublishDir"))))
if !viper.GetBool("DisableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized
livereload.ForceRefresh()
}
}
if dynamic_changed {
fmt.Print("Change detected, rebuilding site\n\n")
utils.StopOnErr(buildSite(true))
if !viper.GetBool("DisableLiveReload") {
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initalized
livereload.ForceRefresh()
}
}
case err := <-watcher.Error:
if err != nil {
fmt.Println("error:", err)
}
}
}
}()
if port > 0 {
if !viper.GetBool("DisableLiveReload") {
livereload.Initialize()
http.HandleFunc("/livereload.js", livereload.ServeJS)
http.HandleFunc("/livereload", livereload.Handler)
}
go serve(port)
}
wg.Wait()
return nil
}
+70
View File
@@ -0,0 +1,70 @@
// +build darwin
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"syscall"
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
)
func init() {
check.AddCommand(limit)
}
var limit = &cobra.Command{
Use: "ulimit",
Short: "Check system ulimit settings",
Long: `Hugo will inspect the current ulimit settings on the system.
This is primarily to ensure that Hugo can watch enough files on some OSs`,
Run: func(cmd *cobra.Command, args []string) {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Error Getting Rlimit ", err)
}
jww.FEEDBACK.Println("Current rLimit:", rLimit)
jww.FEEDBACK.Println("Attempting to increase limit")
rLimit.Max = 999999
rLimit.Cur = 999999
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Error Setting rLimit ", err)
}
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Error Getting rLimit ", err)
}
jww.FEEDBACK.Println("rLimit after change:", rLimit)
},
}
func tweakLimit() {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Unable to obtain rLimit", err)
}
if rLimit.Cur < rLimit.Max {
rLimit.Max = 999999
rLimit.Cur = 999999
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
jww.ERROR.Println("Unable to increase number of open files limit", err)
}
}
}
+19
View File
@@ -0,0 +1,19 @@
// +build !darwin
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
func tweakLimit() {
// nothing to do
}
+253
View File
@@ -0,0 +1,253 @@
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"bytes"
"os"
"path"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/hugo/create"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
var siteType string
var configFormat string
var contentType string
var contentFormat string
var contentFrontMatter string
func init() {
newSiteCmd.Flags().StringVarP(&configFormat, "format", "f", "toml", "config & frontmatter format")
newCmd.Flags().StringVarP(&configFormat, "format", "f", "toml", "frontmatter format")
newCmd.Flags().StringVarP(&contentType, "kind", "k", "", "Content type to create")
newCmd.AddCommand(newSiteCmd)
newCmd.AddCommand(newThemeCmd)
}
var newCmd = &cobra.Command{
Use: "new [path]",
Short: "Create new content for your site",
Long: `Create will create a new content file and automatically set the date and title.
It will guess which kind of file to create based on the path provided.
You can also specify the kind with -k KIND
If archetypes are provided in your theme or site, they will be used.
`,
Run: NewContent,
}
var newSiteCmd = &cobra.Command{
Use: "site [path]",
Short: "Create a new site (skeleton)",
Long: `Create a new site in the provided directory.
The new site will have the correct structure, but no content or theme yet.
Use 'hugo new [contentPath]' to create new content.
`,
Run: NewSite,
}
var newThemeCmd = &cobra.Command{
Use: "theme [name]",
Short: "Create a new theme",
Long: `Create a new theme (skeleton) called [name] in the current directory.
New theme is a skeleton. Please add content to the touched files. Add your
name to the copyright line in the license and adjust the theme.toml file
as you see fit.
`,
Run: NewTheme,
}
func NewContent(cmd *cobra.Command, args []string) {
InitializeConfig()
if cmd.Flags().Lookup("format").Changed {
viper.Set("MetaDataFormat", configFormat)
}
if len(args) < 1 {
cmd.Usage()
jww.FATAL.Fatalln("path needs to be provided")
}
createpath := args[0]
var kind string
// assume the first directory is the section (kind)
if strings.Contains(createpath[1:], "/") {
kind = helpers.GuessSection(createpath)
}
if contentType != "" {
kind = contentType
}
err := create.NewContent(kind, createpath)
if err != nil {
jww.ERROR.Println(err)
}
}
func NewSite(cmd *cobra.Command, args []string) {
if len(args) < 1 {
cmd.Usage()
jww.FATAL.Fatalln("path needs to be provided")
}
createpath, err := filepath.Abs(filepath.Clean(args[0]))
if err != nil {
cmd.Usage()
jww.FATAL.Fatalln(err)
}
if x, _ := helpers.Exists(createpath); x {
y, _ := helpers.IsDir(createpath)
if z, _ := helpers.IsEmpty(createpath); y && z {
jww.INFO.Println(createpath, "already exists and is empty")
} else {
jww.FATAL.Fatalln(createpath, "already exists and is not empty")
}
}
mkdir(createpath, "layouts")
mkdir(createpath, "content")
mkdir(createpath, "archetypes")
mkdir(createpath, "static")
createConfig(createpath, configFormat)
}
func NewTheme(cmd *cobra.Command, args []string) {
InitializeConfig()
if len(args) < 1 {
cmd.Usage()
jww.FATAL.Fatalln("theme name needs to be provided")
}
createpath := helpers.AbsPathify(path.Join("themes", args[0]))
jww.INFO.Println("creating theme at", createpath)
if x, _ := helpers.Exists(createpath); x {
jww.FATAL.Fatalln(createpath, "already exists")
}
mkdir(createpath, "layouts", "_default")
mkdir(createpath, "layouts", "partials")
touchFile(createpath, "layouts", "index.html")
touchFile(createpath, "layouts", "_default", "list.html")
touchFile(createpath, "layouts", "_default", "single.html")
touchFile(createpath, "layouts", "partials", "header.html")
touchFile(createpath, "layouts", "partials", "footer.html")
mkdir(createpath, "archetypes")
touchFile(createpath, "archetypes", "default.md")
mkdir(createpath, "static", "js")
mkdir(createpath, "static", "css")
by := []byte(`The MIT License (MIT)
Copyright (c) 2014 YOUR_NAME_HERE
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
`)
err := helpers.WriteToDisk(path.Join(createpath, "LICENSE.md"), bytes.NewReader(by))
if err != nil {
jww.FATAL.Fatalln(err)
}
createThemeMD(createpath)
}
func mkdir(x ...string) {
p := path.Join(x...)
err := os.MkdirAll(p, 0777) // rwx, rw, r
if err != nil {
jww.FATAL.Fatalln(err)
}
}
func touchFile(x ...string) {
inpath := path.Join(x...)
mkdir(filepath.Dir(inpath))
err := helpers.WriteToDisk(inpath, bytes.NewReader([]byte{}))
if err != nil {
jww.FATAL.Fatalln(err)
}
}
func createThemeMD(inpath string) (err error) {
in := map[string]interface{}{
"name": helpers.MakeTitle(filepath.Base(inpath)),
"license": "MIT",
"source_repo": "",
"author": "",
"description": "",
"tags": []string{"", ""},
}
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune("toml"))
if err != nil {
return err
}
err = helpers.WriteToDisk(path.Join(inpath, "theme.toml"), bytes.NewReader(by))
if err != nil {
return
}
return nil
}
func createConfig(inpath string, kind string) (err error) {
in := map[string]string{"baseurl": "http://yourSiteHere", "title": "my new hugo site", "languageCode": "en-us"}
kind = parser.FormatSanitize(kind)
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))
if err != nil {
return err
}
err = helpers.WriteToDisk(path.Join(inpath, "config."+kind), bytes.NewReader(by))
if err != nil {
return
}
return nil
}
+159
View File
@@ -0,0 +1,159 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"fmt"
"net"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/hugo/helpers"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
var serverPort int
var serverWatch bool
var serverAppend bool
var disableLiveReload bool
//var serverCmdV *cobra.Command
var serverCmd = &cobra.Command{
Use: "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,
}
func init() {
serverCmd.Flags().IntVarP(&serverPort, "port", "p", 1313, "port to run the server on")
serverCmd.Flags().BoolVarP(&serverWatch, "watch", "w", false, "watch filesystem for changes and recreate as needed")
serverCmd.Flags().BoolVarP(&serverAppend, "appendPort", "", true, "append port to baseurl")
serverCmd.Flags().BoolVar(&disableLiveReload, "disableLiveReload", false, "watch without enabling live browser reload on rebuild")
serverCmd.Run = server
}
func server(cmd *cobra.Command, args []string) {
InitializeConfig()
if cmd.Flags().Lookup("disableLiveReload").Changed {
viper.Set("DisableLiveReload", disableLiveReload)
}
if serverWatch {
viper.Set("Watch", true)
}
l, err := net.Listen("tcp", ":"+strconv.Itoa(serverPort))
if err == nil {
l.Close()
} else {
jww.ERROR.Println("port", serverPort, "already in use, attempting to use an available port")
sp, err := helpers.FindAvailablePort()
if err != nil {
jww.ERROR.Println("Unable to find alternative port to use")
jww.ERROR.Fatalln(err)
}
serverPort = sp.Port
}
viper.Set("port", serverPort)
BaseUrl, err := fixUrl(BaseUrl)
if err != nil {
jww.ERROR.Fatal(err)
}
viper.Set("BaseUrl", BaseUrl)
build(serverWatch)
// Watch runs its own server as part of the routine
if serverWatch {
jww.FEEDBACK.Println("Watching for changes in", helpers.AbsPathify(viper.GetString("ContentDir")))
err := NewWatcher(serverPort)
if err != nil {
fmt.Println(err)
}
}
serve(serverPort)
}
func serve(port int) {
jww.FEEDBACK.Println("Serving pages from " + helpers.AbsPathify(viper.GetString("PublishDir")))
jww.FEEDBACK.Printf("Web Server is available at %s\n", viper.GetString("BaseUrl"))
fmt.Println("Press ctrl+c to stop")
fileserver := http.FileServer(http.Dir(helpers.AbsPathify(viper.GetString("PublishDir"))))
u, err := url.Parse(viper.GetString("BaseUrl"))
if err != nil {
jww.ERROR.Fatalf("Invalid BaseUrl: %s", err)
}
if u.Path == "" || u.Path == "/" {
http.Handle("/", fileserver)
} else {
http.Handle(u.Path+"/", http.StripPrefix(u.Path+"/", fileserver))
}
err = http.ListenAndServe(":"+strconv.Itoa(port), nil)
if err != nil {
jww.ERROR.Printf("Error: %s\n", err.Error())
os.Exit(1)
}
}
func fixUrl(s string) (string, error) {
useLocalhost := false
if s == "" {
s = viper.GetString("BaseUrl")
useLocalhost = true
}
if !strings.HasPrefix(s, "http://") {
s = "http://" + s
}
u, err := url.Parse(s)
if err != nil {
return "", err
}
if serverAppend {
if useLocalhost {
u.Host = fmt.Sprintf("localhost:%d", serverPort)
return u.String(), nil
}
host := u.Host
if strings.Contains(host, ":") {
host, _, err = net.SplitHostPort(u.Host)
if err != nil {
return "", fmt.Errorf("Failed to split BaseUrl hostpost: %s", err)
}
}
u.Host = fmt.Sprintf("%s:%d", host, serverPort)
return u.String(), nil
}
if useLocalhost {
u.Host = "localhost"
}
return u.String(), nil
}
+42
View File
@@ -0,0 +1,42 @@
package commands
import (
"testing"
"github.com/spf13/viper"
)
func TestFixUrl(t *testing.T) {
type data struct {
TestName string
CliBaseUrl string
CfgBaseUrl string
AppendPort bool
Port int
Result string
}
tests := []data{
{"Basic localhost", "", "http://foo.com", true, 1313, "http://localhost:1313"},
{"Basic subdir", "", "http://foo.com/bar", true, 1313, "http://localhost:1313/bar"},
{"Basic production", "http://foo.com", "http://foo.com", false, 80, "http://foo.com"},
{"Production subdir", "http://foo.com/bar", "http://foo.com/bar", false, 80, "http://foo.com/bar"},
{"No http", "", "foo.com", true, 1313, "http://localhost:1313"},
{"Override configured port", "", "foo.com:2020", true, 1313, "http://localhost:1313"},
{"No http production", "foo.com", "foo.com", false, 80, "http://foo.com"},
{"No http production with port", "foo.com", "foo.com", true, 2020, "http://foo.com:2020"},
}
for i, test := range tests {
BaseUrl = test.CliBaseUrl
viper.Set("BaseUrl", test.CfgBaseUrl)
serverAppend = test.AppendPort
serverPort = test.Port
result, err := fixUrl(BaseUrl)
if err != nil {
t.Errorf("Test #%d %s: unexpected error %s", err)
}
if result != test.Result {
t.Errorf("Test #%d %s: expected %q, got %q", i, test.TestName, test.Result, result)
}
}
}
+29
View File
@@ -0,0 +1,29 @@
// Copyright © 2013 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package commands
import (
"fmt"
"github.com/spf13/cobra"
)
var version = &cobra.Command{
Use: "version",
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.12")
},
}
+142
View File
@@ -0,0 +1,142 @@
// Copyright © 2014 Steve Francia <spf@spf13.com>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package create
import (
"bytes"
"io/ioutil"
"os"
"path"
"strings"
"time"
"github.com/spf13/cast"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/hugolib"
"github.com/spf13/hugo/parser"
jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
)
func NewContent(kind, name string) (err error) {
jww.INFO.Println("attempting to create ", name, "of", kind)
location := FindArchetype(kind)
var by []byte
if location != "" {
by, err = ioutil.ReadFile(location)
if err != nil {
jww.ERROR.Println(err)
}
}
if location == "" || err != nil {
by = []byte("+++\n title = \"title\"\n draft = true \n+++\n")
}
psr, err := parser.ReadFrom(bytes.NewReader(by))
if err != nil {
return err
}
metadata, err := psr.Metadata()
if err != nil {
return err
}
newmetadata, err := cast.ToStringMapE(metadata)
if err != nil {
return err
}
for k, _ := range newmetadata {
switch strings.ToLower(k) {
case "date":
newmetadata[k] = time.Now()
case "title":
newmetadata[k] = helpers.MakeTitle(helpers.Filename(name))
}
}
caseimatch := func(m map[string]interface{}, key string) bool {
for k, _ := range m {
if strings.ToLower(k) == strings.ToLower(key) {
return true
}
}
return false
}
if !caseimatch(newmetadata, "date") {
newmetadata["date"] = time.Now()
}
if !caseimatch(newmetadata, "title") {
newmetadata["title"] = helpers.MakeTitle(helpers.Filename(name))
}
page, err := hugolib.NewPage(name)
if err != nil {
return err
}
if x := viper.GetString("MetaDataFormat"); x == "json" || x == "yaml" || x == "toml" {
newmetadata["date"] = time.Now().Format(time.RFC3339)
}
page.Dir = viper.GetString("sourceDir")
page.SetSourceMetaData(newmetadata, parser.FormatToLeadRune(viper.GetString("MetaDataFormat")))
if err = page.SafeSaveSourceAs(path.Join(viper.GetString("contentDir"), name)); err != nil {
return
}
jww.FEEDBACK.Println(helpers.AbsPathify(path.Join(viper.GetString("contentDir"), name)), "created")
return nil
}
func FindArchetype(kind string) (outpath string) {
search := []string{helpers.AbsPathify(viper.GetString("archetypeDir"))}
if viper.GetString("theme") != "" {
themeDir := path.Join(helpers.AbsPathify("themes/"+viper.GetString("theme")), "/archetypes/")
if _, err := os.Stat(themeDir); os.IsNotExist(err) {
jww.ERROR.Println("Unable to find archetypes directory for theme :", viper.GetString("theme"), "in", themeDir)
} else {
search = append(search, themeDir)
}
}
for _, x := range search {
// If the new content isn't in a subdirectory, kind == "".
// Therefore it should be excluded otherwise `is a directory`
// error will occur. github.com/spf13/hugo/issues/411
var pathsToCheck []string
if kind == "" {
pathsToCheck = []string{"default.md", "default"}
} else {
pathsToCheck = []string{kind + ".md", kind, "default.md", "default"}
}
for _, p := range pathsToCheck {
curpath := path.Join(x, p)
jww.DEBUG.Println("checking", curpath, "for archetypes")
if exists, _ := helpers.Exists(curpath); exists {
jww.INFO.Println("curpath: " + curpath)
return curpath
}
}
}
return ""
}
+6
View File
@@ -0,0 +1,6 @@
+++
weight = 5
[menu]
[menu.main]
parent = "x"
+++
+14
View File
@@ -0,0 +1,14 @@
---
date: 2013-07-01T07:32:00Z
description: ""
license: ""
licenseLink: ""
sitelink: http://spf13.com
sourceLink: http://github.com/spf13/spf13.com
tags:
- personal
- blog
thumbnail: /img/spf13-tn.jpg
title: spf13.com
---
-4
View File
@@ -1,4 +0,0 @@
{
"Indexes" : {"tag": "tags"},
"BaseUrl" : "http://localhost"
}
+56
View File
@@ -0,0 +1,56 @@
baseurl = "http://hugo.spf13.com"
MetaDataFormat = "yaml"
[indexes]
tag = "tags"
group = "groups"
[[menu.main]]
name = "Download Hugo"
pre = "<i class='fa fa-download'></i>"
url = "https://github.com/spf13/hugo/releases"
weight = -200
[[menu.main]]
name = "Showcase"
pre = "<i class='fa fa-cubes'></i>"
url = "/showcase/"
weight = -200
[[menu.main]]
name = "about hugo"
pre = "<i class='fa fa-heart'></i>"
weight = -110
identifier = "about"
[[menu.main]]
name = "getting started"
pre = "<i class='fa fa-road'></i>"
weight = -100
[[menu.main]]
name = "content"
pre = "<i class='fa fa-file-text'></i>"
weight = -90
[[menu.main]]
name = "themes"
pre = "<i class='fa fa-desktop'></i>"
weight = -85
[[menu.main]]
name = "templates"
identifier = "layout"
pre = "<i class='fa fa-columns'></i>"
weight = -80
[[menu.main]]
name = "taxonomies"
identifier = "taxonomy"
pre = "<i class='fa fa-tags'></i>"
weight = -70
[[menu.main]]
name = "extras"
pre = "<i class='fa fa-gift'></i>"
weight = -60
[[menu.main]]
name = "tutorials"
pre = "<i class='fa fa-book'></i>"
weight = -40
[[menu.main]]
name = "community"
pre = "<i class='fa fa-group'></i>"
weight = -50
+67
View File
@@ -0,0 +1,67 @@
---
aliases:
- /doc/contributing/
- /meta/contributing/
date: 2013-07-01
menu:
main:
parent: community
next: /tutorials/github_pages_blog
prev: /community/press
title: Contributing to Hugo
weight: 30
---
All contributions to Hugo are welcome. Whether you want to scratch an itch, or simply contribute to the project, feel free to pick something from the roadmap
or contact [spf13](http://spf13.com) about what may make sense
to do next.
You should fork the project and make your changes. *We encourage pull requests to discuss code changes.*
When you're ready to create a pull request, be sure to:
* Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
* Run `go fmt`
* Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request.
* Make sure `go test ./...` passes, and `go build` completes. Our Travis CI loop will catch most things that are missing. The exception: Windows. We run on Windows from time to time, but if you have access, please check on a Windows machine too.
## Contribution Overview
1. Fork Hugo from https://github.com/spf13/hugo
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Commit passing tests to validate changes.
5. Run `go fmt`
6. Squash commits into a single (or logically grouped) commits (`git rebase -i`)
7. Push to the branch (`git push origin my-new-feature`)
8. Create new Pull Request
# Building from source
## Clone locally (for contributors):
git clone https://github.com/spf13/hugo
cd hugo
go get
Because Go expects all of your libraries to be found in either
$GOROOT or $GOPATH, it's helpful to symlink the project to one
of the following paths:
* ln -s /path/to/your/hugo $GOPATH/src/github.com/spf13/hugo
* ln -s /path/to/your/hugo $GOROOT/src/pkg/github.com/spf13/hugo
## Running Hugo
cd /path/to/hugo
go install github.com/spf13/hugo/hugo
go run main.go
## Building Hugo
cd /path/to/hugo
go build -o hugo main.go
mv hugo /usr/local/bin/
+38
View File
@@ -0,0 +1,38 @@
---
date: 2013-07-01
menu:
main:
parent: community
next: /community/press
prev: /extras/urls
title: Mailing List
weight: 10
---
Hugo has two mailing lists:
## Announcements
Very low traffic. Only releases will be emailed here.
https://groups.google.com/forum/#!forum/hugo-announce
## Discussion
For all questions and discussions:
https://groups.google.com/forum/#!forum/hugo-discuss
# Other Resources
## GoNuts
For general Go questions or discussion please refer to the Go mailing list.
https://groups.google.com/forum/#!forum/golang-nuts
## GitHub Issues
https://github.com/spf13/hugo/issues
## Twitter
Hugo doesn't have its own Twitter handle, but feel free to tweet [@spf13](http://twitter.com/spf13).
+65
View File
@@ -0,0 +1,65 @@
---
date: 2014-03-24T20:00:00Z
linktitle: Press
menu:
main:
parent: community
next: /community/contributing
notoc: true
prev: /community/mailing-list
title: Press, Blogs and Media Coverage
weight: 20
---
Hugo has been featured in the following Blog Posts, Press and Media.
| Title | Author | Date |
| ------ | ------ | -----: |
| [Hugo para crear sitios web estáticos](http://www.webbizarro.com/noticias/1076/hugo-para-crear-sitios-web-estaticos/) | Web Bizarro | 19 Aug 2014 |
| [Hello Hugo!](http://commiechink.com/2014/08/hello-hugo/) | Jason Yee | 19 Aug 2014 |
| [Going with hugo](http://www.markuseliasson.se/article/going-with-hugo/) | Markus Eliasson | 18 Aug 2014 |
| [Benchmarking Jekyll, Hugo and Wintersmith](http://www.internaldeployment.se/post/2014-08-12-Jekyll-and-its-alternatives-from-a-site-generation-point-of-view/) | Fredrik Loch | 12 Aug 2014 |
| [Goodbye Octopress, Hello Hugo!](http://andreimihu.com/blog/2014/08/11/goodbye-octopress-hello-hugo/) | Andrei Mihu | 11 Aug 2014 |
| [Beautiful sites for Open Source projects](http://beautifulopen.com/2014/08/09/hugo/) | Beautiful Open | 9 Aug 2014 |
| [Hugo: Beyond the Defaults](http://npf.io/2014/08/hugo-beyond-the-defaults/) | Nate Finch | 8 Aug 2014 |
| [First Impressions of Hugo](https://peteraba.com/blog/first-impressions-of-hugo/) | Peter Aba | 6 Aug 2014 |
| [New Site Workflow](http://vurt.co.uk/post/new_website/) | Giles Paterson | 5 Aug 2014 |
| [How I Learned to Stop Worrying and Love the (Static) Web](http://cognition.ca/post/about-hugo/) | Joshua McKenty | 4 Aug 2014 |
| [Hugo over Octopress](http://kennywoo.com/blog/hugo---golang-based-static-site-generator/) | Kenny Woo | 3 Aug 2014 |
| [Hugo Is Friggin' Awesome](http://npf.io/2014/08/hugo-is-awesome/) | Nate Finch | 1 Aug 2014 |
| [Embedding Gists in Hugo](http://danmux.com/posts/embedded_gists/) | Dan Mull | 5 July 2014 |
| [An Introduction To Hugo](http://www.cirrushosting.com/web-hosting-blog/an-introduction-to-hugo/) | Dan Silber | 1 July 2014 |
| [Moving to Hugo](http://danmux.com/posts/hugo_based_blog/) | Dan Mull | 29 May 2014 |
| [开源之静态站点生成器排行榜](http://code.csdn.net/news/2819909) | csdn.net | 23 May 2014 |
| [How I deploy this site using Fabric](http://carlorat.me/quote/fabric/) | Carlo Ratam | 21 May 2014 |
| [Finally, a satisfying and effective blog setup](http://michaelwhatcott.com/now-powered-by-hugo/) | Michael Whatcott | 20 May 2014 |
| [Hugo from scratch](http://zackofalltrades.com/notes/2014/05/hugo-from-scratch/) | Zack Williams | 18 May 2014 |
| [Why I switched away from Jekyll](http://www.jakejanuzelli.com/why-I-switched-away-from-jekyll/) | Jake Januzelli | 10 May 2014 |
| [Welcome our new blog](http://blog.ninya.io/posts/welcome-our-new-blog/) | Ninya.io | 11 Apr 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 |
| [Adventures in Angular Podcast](http://devchat.tv/adventures-in-angular/003-aia-gdes) | Matias Niemela | 28 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 |
| [Moving to Hugo Static Web Pages](http://tepid.org/tech/hugo-web/) | Tobias Weingartner | 16 Mar 2014 |
| [Hugo and Github Pages](http://sglyon.com/blog/2014/creating-the-site/) | Spencer Lyon | 15 Mar 2014 |
| [New Blog Engine: Hugo](https://blog.afoolishmanifesto.com/posts/hugo/) | fREW Schmidt | 15 Mar 2014 |
| [Hugo + gulp.js = Huggle](http://ktmud.github.io/huggle/intro/) | Jesse Yang | 8 Mar 2014 |
| [Powered by Hugo](http://kieranhealy.org/blog/archives/2014/02/24/powered-by-hugo/) | Kieran Healy | 24 Feb 2014 |
| [静的サイトを素早く構築するためにGoLangで作られたジェネレータHugo](http://hamasyou.com/blog/2014/02/21/hugo/) | Shogo Hamada | 21 Feb 2014 |
| [Latest Roundup of Useful Tools For Developers](http://codegeekz.com/latest-roundup-of-useful-tools-for-developers/) | CodeGeekz | 13 Feb 2014 |
| [Hugo: Static Site Generator written in Go](http://www.braveterry.com/2014/02/06/hugo-static-site-generator-written-in-go/) | Brave Terry | 6 Feb 2014 |
| [10 Useful HTML5 Tools for Web Designers and Developers](http://designdizzy.com/10-useful-html5-tools-for-web-designers-and-developers/) | Design Dizzy | 4 Feb 2014 |
| [Hugo Fast, Flexible Static Site Generator](http://cube3x.com/hugo-fast-flexible-static-site-generator/) | Joby Joseph | 18 Jan 2014 |
| [Hugo: A new way to build static website](http://www.w3update.com/opensource/hugo-a-new-way-to-build-static-website.html) | w3update | 17 Jan 2014 |
| [Xaprb now uses Hugo](http://xaprb.com/blog/2014/01/15/using-hugo/) | Baron Schwartz | 15 Jan 2014 |
| [New jQuery Plugins And Resources That Web Designers Need](http://www.designyourway.net/blog/resources/new-jquery-plugins-and-resources-that-web-designers-need/) | Design Your Way | 2014 |
| [On Blog Construction](http://alexla.sh/post/on-blog-construction/) | Alexander Lash | 27 Dec 2013 |
| [Hugo](http://onethingwell.org/post/69070926608/hugo) | One Thing Well | 5 Dec 2013 |
| [In Praise Of Hugo](http://sound-guru.com/blog/post/hello-world/) | sound-guru.com | 19 Oct 2013 |
| [Hosting a blog on S3 and Cloudfront](http://www.danesparza.net/2013/07/hosting-a-blog-on-s3-and-cloudfront/) | Dan Esparza | 24 July 2013 |
### Wrote a post, article or tutorial?
Have you written a post, article or tutorial on hugo? Send us a pull request or issue with the addition.
+75
View File
@@ -0,0 +1,75 @@
---
date: 2014-05-14T02:13:50Z
menu:
main:
parent: content
next: /content/ordering
prev: /content/types
title: Archetypes
weight: 50
---
Hugo v0.11 introduced the concept of a content builder. Using the
command: `hugo new [relative new content path]` you can start a content file
with the date and title automatically set. This is a welcome feature, but
active writers need more.
Hugo presents the concept of archetypes which are archetypal content files.
## Example archetype
In this example scenario I have a blog with a single content type (blog post).
I use tags and categories for my taxonomies.
### archetypes/default.md
+++
tags = ["x", "y"]
categories = ["x", "y"]
+++
## using archetypes
If I wanted to create a new post in the `posts` section I would run the following command...
`hugo new posts/my-new-post.md`
Hugo would create the file with the following contents:
### contents/posts/my-new-post.md
+++
title = "my new post"
date = 2014-05-14T02:13:50Z
tags = ["x", "y"]
categories = ["x", "y"]
+++
## Using a different front matter format
By default the front matter will be created in the TOML format
regardless of what format the archetype is using.
You can specify a different default format in your config file using
the `MetaDataFormat` directive. Possible values are `toml`, `yaml` and `json`.
## Which archtype is being used
The following rules apply:
* If an archetype with a filename that matches the content type being created it will be used.
* If no match is found `archetypes/default.md` will be used.
* If neither are present and a theme is in use then within the theme...
* If an archetype with a filename that matches the content type being created it will be used.
* If no match is found `archetypes/default.md` will be used.
* If no archetype files are present then the one that ships with hugo will be used.
Hugo provides a simple archetype which sets the title (based on the
file name) and the date based on now().
Content type is automatically detected based on the path. You are welcome to declare which
type to create using the `--kind` flag during creation.
+49
View File
@@ -0,0 +1,49 @@
---
aliases:
- /doc/example/
date: 2013-07-01
linktitle: Example
menu:
main:
parent: content
next: /themes/overview
notoc: true
prev: /content/ordering
title: Example Content File
weight: 70
---
Somethings are better shown than explained. The following is a very basic example of a content file:
**mysite/project/nitro.md <- http://mysite.com/project/nitro.html**
---
Title: "Nitro : A quick and simple profiler for Go"
Description: "Nitro is a simple profiler for you go lang applications"
Tags: [ "Development", "Go", "profiling" ]
date: "2013-06-19"
Topics: [ "Development", "Go" ]
Slug: "nitro"
project_url: "http://github.com/spf13/nitro"
---
# Nitro
Quick and easy performance analyzer library for Go.
## Overview
Nitro is a quick and easy performance analyzer library for Go.
It is useful for comparing A/B against different drafts of functions
or different functions.
## Implementing Nitro
Using Nitro is simple. First use go get to install the latest version
of the library.
$ go get github.com/spf13/nitro
Next include nitro in your application.
+94
View File
@@ -0,0 +1,94 @@
---
aliases:
- /doc/front-matter/
date: 2013-07-01
menu:
main:
parent: content
next: /content/sections
prev: /content/organization
title: Front Matter
weight: 20
---
The front matter is one of the features that gives Hugo its strength. It enables
you to include the meta data of the content right with it. Hugo supports a few
different formats each with their own identifying tokens.
Supported formats: <br>
**YAML**, identified by '\-\-\-'. <br>
**TOML**, indentified with '+++'.<br>
**JSON**, a single JSON object which is surrounded by '{' and '}' each on their own line.
### YAML Example
---
title: "spf13-vim 3.0 release and new website"
description: "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags: [ ".vimrc", "plugins", "spf13-vim", "vim" ]
date: "2012-04-06"
categories:
- "Development"
- "VIM"
slug: "spf13-vim-3-0-release-and-new-website"
---
Content of the file goes Here
### TOML Example
+++
title = "spf13-vim 3.0 release and new website"
description = "spf13-vim is a cross platform distribution of vim plugins and resources for Vim."
tags = [ ".vimrc", "plugins", "spf13-vim", "vim" ]
date = "2012-04-06"
categories = [
"Development",
"VIM"
]
slug = "spf13-vim-3-0-release-and-new-website"
+++
Content of the file goes Here
### JSON Example
{
"title": "spf13-vim 3.0 release and new website",
"description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
"date": "2012-04-06",
"categories": [
"Development",
"VIM"
],
"slug": "spf13-vim-3-0-release-and-new-website",
}
Content of the file goes Here
## Variables
There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want to. These will be placed into the `.Params` variable available to the templates.
Field names are always normalized to lowercase (eg. `camelCase: true` is available as `.Params.camelcase`).
### Required
* **title** The title for the content
* **description** The description for the content
* **date** The date the content will be sorted by
* **taxonomies** These will use the field name of the plural form of the index (see tags and categories above)
### Optional
* **redirect** Mark the post as a redirect post
* **draft** If true, the content will not be rendered unless `hugo` is called with `--buildDrafts`
* **publishdate** If in the future, content will not be rendered unless `hugo` is called with `--buildFuture`
* **type** The type of the content (will be derived from the directory automatically if unset)
* **weight** Used for sorting
* **markup** (Experimental) Specify "rst" for reStructuredText (requires
`rst2html`,) or "md" (default) for the Markdown
* **slug** The token to appear in the tail of the URL
*or*<br>
* **url** The full path to the content from the web root.<br>
*If neither slug or url is present, the filename will be used.*
+39
View File
@@ -0,0 +1,39 @@
---
date: 2014-03-06
linktitle: Ordering
menu:
main:
parent: content
next: /content/example
prev: /content/archetypes
title: Ordering Content
weight: 60
---
Hugo provides you with all the flexibility you need to organize how your content is ordered.
By default, content is ordered by weight, then by date with the most
recent date first, but alternative sorting (by title and linktitle) is
also available. The order the content will appear will be specified in
the [list template](/templates/list).
_Both the date and weight fields are optional._
Unweighted pages appear at the end of the list. If no weights are provided (or
if weights are the same) date will be used to sort. If neither are provided
content will be ordered based on how it's read off the disk and no order is
guaranteed.
## Assigning Weight to content
+++
weight = "4"
title = "Three"
date = "2012-04-06"
+++
Front Matter with Ordered Pages 3
## Ordering Content Within Taxonomies
Please see the [Taxonomy Ordering Documentation](/taxonomies/ordering/)
+164
View File
@@ -0,0 +1,164 @@
---
aliases:
- /doc/organization/
date: 2013-07-01
linktitle: Organization
menu:
main:
parent: content
next: /content/front-matter
prev: /overview/source-directory
title: Content Organization
weight: 10
---
Hugo uses markdown files with headers commonly called the front matter. Hugo
respects the organization that you provide for your content to minimize any
extra configuration, though this can be overridden by additional configuration
in the front matter.
## Organization
In Hugo the content should be arranged in the same way they are intended for
the rendered website. Without any additional configuration the following will
just work. Hugo supports content nested at any level. The top level is special
in Hugo and is used as the [section](/content/sections).
.
└── content
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://1.com/post/secondpost/
└── quote
├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://1.com/quote/second/
**Here's the same organization run with hugo -\-uglyurls**
.
└── content
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost.html
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness.html
| └── secondpost.md // <- http://1.com/post/secondpost.html
└── quote
├── first.md // <- http://1.com/quote/first.html
└── second.md // <- http://1.com/quote/second.html
## Destinations
Hugo thinks that you organize your content with a purpose. The same structure
that works to organize your source content is used to organize the rendered
site. As displayed above, the organization of the source content will be
mirrored in the destination.
There are times when one would need more control over their content. In these
cases there are a variety of things that can be specified in the front matter to
determine the destination of a specific piece of content.
The following items are defined in order, latter items in the list will override
earlier settings.
### filename
This isn't in the front matter, but is the actual name of the file minus the
extension. This will be the name of the file in the destination.
### slug
Defined in the front matter, the slug can take the place of the filename for the
destination.
### filepath
The actual path to the file on disk. Destination will create the destination
with the same path. Includes [section](/content/sections).
### section
section can be provided in the front matter overriding the section derived from
the source content location on disk. See [section](/content/sections).
### path
path can be provided in the front matter. This will replace the actual
path to the file on disk. Destination will create the destination with the same
path. Includes [section](/content/sections).
### url
A complete url can be provided. This will override all the above as it pertains
to the end destination. This must be the path from the baseurl (starting with a "/").
When a url is provided it will be used exactly. Using url will ignore the
-\-uglyurls setting.
## Path breakdown in Hugo
### Content
. path slug
. ⊢-------^----⊣ ⊢------^-------⊣
content/extras/indexes/category-example/index.html
. section slug
. ⊢--^--⊣ ⊢------^-------⊣
content/extras/indexes/category-example/index.html
. section slug
. ⊢--^--⊣⊢--^--⊣
content/extras/indexes/index.html
### Destination
permalink
⊢--------------^-------------⊣
http://spf13.com/projects/hugo
baseUrl section slug
⊢-----^--------⊣ ⊢--^---⊣ ⊢-^⊣
http://spf13.com/projects/hugo
baseUrl section slug
⊢-----^--------⊣ ⊢--^--⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
baseUrl path slug
⊢-----^--------⊣ ⊢------^-----⊣ ⊢--^--⊣
http://spf13.com/extras/indexes/example
baseUrl url
⊢-----^--------⊣ ⊢-----^-----⊣
http://spf13.com/projects/hugo
baseUrl url
⊢-----^--------⊣ ⊢--------^-----------⊣
http://spf13.com/extras/indexes/example
**section** = which type the content is by default
* based on content location
* front matter overrides
**slug** = name.ext or name/
* based on content-name.md
* front matter overrides
**path** = section + path to file excluding slug
* based on path to content location
**url** = relative URL
* defined in front matter
* overrides all the above
+51
View File
@@ -0,0 +1,51 @@
---
date: 2013-07-01
menu:
main:
parent: content
next: /content/types
notoc: true
prev: /content/front-matter
title: Sections
weight: 30
---
Hugo thinks that you organize your content with a purpose. The same structure
that works to organize your source content is used to organize the rendered
site (see [Organization](/content/organization)). Following this pattern Hugo
uses the top level of your content organization as **the Section**.
The following example site uses two sections, "post" and "quote".
.
└── content
├── post
| ├── firstpost.md // <- http://1.com/post/firstpost/
| ├── happy
| | └── ness.md // <- http://1.com/post/happy/ness/
| └── secondpost.md // <- http://1.com/post/secondpost/
└── quote
├── first.md // <- http://1.com/quote/first/
└── second.md // <- http://1.com/quote/second/
## Section Lists
Hugo will automatically create pages for each section root that list all
of the content in that section. See [List Templates](/templates/list)
for details on customizing the way they appear.
## Sections and Types
By default everything created within a section will use the content type
that matches the section name.
Section defined in the front matter have the same impact.
To change the type of a given piece of content, simply define the type
in the front matter.
If a layout for a given type hasn't been provided, a default type template will
be used instead provided it exists.
+76
View File
@@ -0,0 +1,76 @@
---
date: 2013-07-01
linktitle: Types
menu:
main:
parent: content
next: /content/archetypes
prev: /content/sections
title: Content Types
weight: 40
---
Hugo has full support for different types of content. A content type can have a
unique set of meta data, template and can be automatically created by the new
command through using content [archetypes](/content/archetypes).
A good example of when multiple types are needed is to look at Tumblr. A piece
of content could be a photo, quote or post, each with different meta data and
rendered differently.
## Assigning a content type
Hugo assumes that your site will be organized into [sections](/content/sections)
and each section will use the corresponding type. If you are taking advantage of
this then each new piece of content you place into a section will automatically
inherit the type.
Alternatively you can set the type in the meta data under the key "type".
## Creating new content of a specific type
Hugo has the ability to create a new content file and populate the front matter
with the data set corresponding to that type. Hugo does this by utilizing
[archetypes](/content/archetypes).
To create a new piece of content use:
hugo new relative/path/to/content.md
For example if I wanted to create a new post inside the post section I would type:
hugo new post/my-newest-post.md
## Defining a content type
Creating a new content type is easy in Hugo. You simply provide the templates and archetype
that the new type will use. You only need to define the templates, archetypes and/or views
unique to that content type. Hugo will fall back to using the general templates and default archetype
whenever a specific file is not present.
*Remember, all of the following are optional:*
### Create Type Directory
Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*.
### Create single template
Create a file called single.html inside your directory. *Eg /layouts/post/single.html*.
### Create list template
Create a file called list.html inside your directory *Eg /layouts/post/list.html*.
### Create views
Many sites support rendering content in a few different ways, for
instance a single page view and a summary view to be used when displaying a list
of contents on a single page. Hugo makes no assumptions here about how you want
to display your content, and will support as many different views of a content
type as your site requires. All that is required for these additional views is
that a template exists in each layout/type directory with the same name.
### Create a corresponding archetype
Create a file called `type`.md in the /archetypes directory *Eg /archetypes/post.md*.
More details about archetypes can be found at the [archetypes docs](/content/archetypes)
-19
View File
@@ -1,19 +0,0 @@
{
"title": "Configuring Hugo",
"Pubdate": "2013-07-01"
}
The directory structure and templates provide the majority of the
configuration for a site. In fact a config file isn't even needed for many websites
since the defaults used follow commonly used patterns.
The following is an example of a config file with the default values
{
"SourceDir" : "content",
"LayoutDir" : "layouts",
"PublishDir" : "public",
"BuildDrafts" : false,
"Tags" : { "category" : "categories", "tag" : "tags" },
"BaseUrl" : "http://yourSite.com/"
}
-10
View File
@@ -1,10 +0,0 @@
{
"title": "Contributing to Hugo",
"Pubdate": "2013-07-01"
}
1. Fork it from https://github.com/spf13/hugo
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
-9
View File
@@ -1,9 +0,0 @@
{
"title": "Contributors",
"Pubdate": "2013-07-01"
}
Hugo was built with love and golang by:
* [spf13](https://github.com/spf13)
-40
View File
@@ -1,40 +0,0 @@
{
"title": "Example Content File",
"Pubdate": "2013-07-01"
}
Somethings are better shown than explained. The following is a very basic example of a content file:
**mysite/project/nitro.md <- http://mysite.com/project/nitro.html**
{
"Title": "Nitro : A quick and simple profiler for golang",
"Description": "",
"Keywords": [ "Development", "golang", "profiling" ],
"Tags": [ "Development", "golang", "profiling" ],
"Pubdate": "2013-06-19",
"Topics": [ "Development", "GoLang" ],
"Slug": "nitro",
"project_url": "http://github.com/spf13/nitro"
}
# Nitro
Quick and easy performance analyzer library for golang.
## Overview
Nitro is a quick and easy performance analyzer library for golang.
It is useful for comparing A/B against different drafts of functions
or different functions.
## Implementing Nitro
Using Nitro is simple. First use go get to install the latest version
of the library.
$ go get github.com/spf13/nitro
Next include nitro in your application.
-38
View File
@@ -1,38 +0,0 @@
{
"title": "Front Matter",
"Pubdate": "2013-07-01"
}
The front matter is one of the features that gives Hugo it's strength. It enables
you to include the meta data of the content right with it. Hugo supports a few
different formats. The main format supported is JSON. Here is an example:
{
"Title": "spf13-vim 3.0 release and new website",
"Description": "spf13-vim is a cross platform distribution of vim plugins and resources for Vim.",
"Tags": [ ".vimrc", "plugins", "spf13-vim", "vim" ],
"Pubdate": "2012-04-06",
"Categories": [ "Development", "VIM" ],
"Slug": "spf13-vim-3-0-release-and-new-website"
}
### Variables
There are a few predefined variables that Hugo is aware of and utilizes. The user can also create
any variable they want to. These will be placed into the `.Params` variable available to the templates.
#### Required
**Title** The title for the content. <br>
**Description** The description for the content.<br>
**Pubdate** The date the content will be sorted by.<br>
**Indexes** These will use the field name of the plural form of the index (see tags and categories above)
#### Optional
**Draft** If true the content will not be rendered unless `hugo` is called with -d<br>
**Type** The type of the content (will be derived from the directory automatically if unset).<br>
**Slug** The token to appear in the tail of the url.<br>
*or*<br>
**Url** The full path to the content from the web root.<br>
*If neither is present the filename will be used.*
-28
View File
@@ -1,28 +0,0 @@
{
"title": "Installing Hugo",
"Pubdate": "2013-07-01"
}
Installation is very easy. Simply download the appropriate version for your
platform.
Hugo is written in GoLang with support for Windows, Linux and OSX.
<div class="alert alert-info">
Please make sure that you place the executable in your path. `/usr/local/bin`
is the most probable location.
</div>
Hugo doesn't have any external dependencies, but can benefit from external
programs.
## Installing from source
Make sure you have a recent version of go installed. Hugo requires go 1.1+.
git clone https://github.com/spf13/hugo
cd hugo
go build -o hugo main.go
-22
View File
@@ -1,22 +0,0 @@
{
"title": "Organization",
"Pubdate": "2013-07-01"
}
Hugo uses markdown files with headers commonly called the front matter. Hugo respects the organization
that you provide for your content to minimize any extra configuration, though this can be overridden
by additional configuration in the front matter.
## Organization
In Hugo the content should be arranged in the same way they are intended for the rendered website.
Without any additional configuration the following will just work.
.
└── content
├── post
| ├── firstpost.md // <- http://site.com/post/firstpost.html
| └── secondpost.md // <- http://site.com/post/secondpost.html
└── quote
├── first.md // <- http://site.com/quote/first.html
└── second.md // <- http://site.com/quote/second.html
-14
View File
@@ -1,14 +0,0 @@
{
"title": "Release Notes",
"Pubdate": "2013-07-01"
}
* **0.7.0** July 4, 2013
* Hugo now includes a simple server
* First public release
* **0.6.0** July 2, 2013
* Hugo includes an example documentation site which it builds
* **0.5.0** June 25, 2013
* Hugo is quite usable and able to build spf13.com
-18
View File
@@ -1,18 +0,0 @@
{
"title": "Roadmap",
"Pubdate": "2013-07-01"
}
In no particular order, here is what I'm working on:
* Pagination
* Support for top level pages (other than homepage)
* Series support
* Syntax highlighting
* Previous & Next
* Related Posts
* Support for TOML front matter
* Proper YAML support for front matter
* Support for other formats
-76
View File
@@ -1,76 +0,0 @@
{
"title": "Shortcodes",
"Pubdate": "2013-07-01"
}
Because Hugo uses markdown for it's content format, it was clear that there's a lot of things that
markdown doesn't support well. This is good, the simple nature of markdown is exactly why we chose it.
However we cannot accept being constrained by our simple format. Also unacceptable is writing raw
html in our markdown every time we want to include unsupported content such as a video. To do
so is in complete opposition to the intent of using a bare bones format for our content and
utilizing templates to apply styling for display.
To avoid both of these limitations Hugo has full support for shortcodes.
### What is a shortcode?
A shortcode is a simple snippet inside a markdown file that Hugo will render using a template.
Short codes are designated by the opening and closing characters of '{{&#37;' and '%}}' respectively.
Short codes are space delimited. The first word is always the name of the shortcode. Following the
name are the parameters. The author of the shortcode can choose if the short code
will use positional parameters or named parameters (but not both). A good rule of thumb is that if a
short code has a single required value in the case of the youtube example below then positional
works very well. For more complex layouts with optional parameters named parameters work best.
The format for named parameters models that of html with the format name="value"
### Example: youtube
*Example has an extra space so Hugo doesn't actually render it*
{{ % youtube 09jf3ow9jfw %}}
This would be rendered as
<div class="embed video-player">
<iframe class="youtube-player" type="text/html"
width="640" height="385"
src="http://www.youtube.com/embed/09jf3ow9jfw"
allowfullscreen frameborder="0">
</iframe>
</div>
### Example: image with caption
*Example has an extra space so Hugo doesn't actually render it*
{{ % img src="/media/spf13.jpg" title="Steve Francia" %}}
Would be rendered as:
<figure >
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
### Creating a shortcode
All that you need to do to create a shortcode is place a template in the layouts/shortcodes directory.
The template name will be the name of the shortcode.
**Inside the template**
To access a parameter by either position or name the index method can be used.
{{ index .Params 0 }}
or
{{ index .Params "class" }}
To check if a parameter has been provided use the isset method provided by Hugo.
{{ if isset .Params "class"}} class="{{ index .Params "class"}}" {{ end }}
-66
View File
@@ -1,66 +0,0 @@
{
"title": "Templates",
"Pubdate": "2013-07-01"
}
Hugo uses the excellent golang html/template library for it's template engine. It is an extremely
lightweight engine that provides a very small amount of logic. In our
experience that it is just the right amount of logic to be able to create a good static website
This document will not cover how to use golang templates, but the [golang docs](http://golang.org/pkg/html/template/)
provide a good introduction.
### Template roles
There are 5 different kinds of templates that Hugo works with.
#### index.html
This file must exist in the layouts directory. It is the template used to render the
homepage of your site.
#### rss.xml
This file must exist in the layouts directory. It will be used to render all rss documents.
The one provided in the example application will generate an ATOM format.
*Important: Hugo will automatically add the following header line to this file.*
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
#### Indexes
An index is a page that list multiple pieces of content. If you think of a typical blog, the tag
pages are good examples of indexes.
#### Content Type(s)
Hugo supports multiple types of content. Another way of looking at this is that Hugo has the ability
to render content in a variety of ways as determined by the type.
#### Chrome
Chrome is simply the decoration of your site. It's not a requirement to have this, but in practice
it's very convenient. Hugo doesn't know anything about Chrome, it's simply a convention that you may
likely find beneficial. As you create the rest of your templates you will include templates from the
/layout/chrome directory. I've found it helpful to include a header and footer template
in Chrome so I can include those in the other full page layouts (index.html, indexes/ type/single.html).
### Adding a new content type
Adding a type is easy.
**Step 1:**
Create a directory with the name of the type in layouts.Type is always singular. *Eg /layouts/post*.
**Step 2:**
Create a file called single.html inside your directory. *Eg /layouts/post/single.html*.
**Step 3:**
Create a file with the same name as your directory in /layouts/indexes/. *Eg /layouts/index/post.html*.
**Step 4:**
Many sites support rendering content in a few different ways, for instance a single page view and a
summary view to be used when displaying a list of contents on a single page. Hugo makes no assumptions
here about how you want to display your content, and will support as many different views of a content
type as your site requires. All that is required for these additional views is that a template
exists in each layout/type directory with the same name.
For these, reviewing this example site will be very helpful in order to understand how these types work.
-52
View File
@@ -1,52 +0,0 @@
{
"title": "Using Hugo",
"Pubdate": "2013-07-01"
}
Make sure either hugo is in your path or provide a path to it.
$ hugo --help
usage: hugo [flags] []
-b="": hostname (and path) to the root eg. http://spf13.com/
-c="config.json": config file (default is path/config.json)
-d=false: include content marked as draft
-h=false: show this help
-k=false: analyze content and provide feedback
-p="": filesystem path to read files relative from
-w=false: watch filesystem for changes and recreate as needed
-s=false: a (very) simple webserver
-p="1313": port for webserver to run on
## Common Usage Example:
The most common use is probably to run hugo with your current
directory being the input directory.
$ hugo
> X pages created
> Y indicies created
If you are working on things and want to see the changes
immediately, tell Hugo to watch for changes.
<br>
**It will
recreate the site faster than you can tab over to
your browser to view the changes.**
$ hugo -p ~/mysite -w
Watching for changes. Press ctrl+c to stop
15 pages created
0 tags created
Hugo can even run a server and create your site at the same time!
$hugo -p ~/mysite -w -s
Watching for changes. Press ctrl+c to stop
15 pages created
0 tags created
Web Server is available at http://localhost:1313
Press ctrl+c to stop
-29
View File
@@ -1,29 +0,0 @@
{
"title": "Variables",
"Pubdate": "2013-07-01"
}
Hugo makes a set of values available to the templates. Go templates are context based. The following
are available in the context for the templates.
**.Title** The title for the content. <br>
**.Description** The description for the content.<br>
**.Keywords** The meta keywords for this content.<br>
**.Date** The date the content is published on.<br>
**.Indexes** These will use the field name of the plural form of the index (see tags and categories above)<br>
**.Permalink** The Permanent link for this page.<br>
**.FuzzyWordCount** The approximate number of words in the content.<br>
**.RSSLink** Link to the indexes' rss link <br>
Any value defined in the front matter, including indexes will be made available under `.Params`.
Take for example I'm using tags and categories as my indexes. The following would be how I would access them:
**.Params.Tags** <br>
**.Params.Categories** <br>
Also available is `.Site` which has the following:
**.Site.BaseUrl** The base URL for the site as defined in the config.json file.<br>
**.Site.Indexes** The names of the indexes of the site.<br>
**.Site.LastChange** The date of the last change of the most recent content.<br>
**.Site.Recent** Array of all content ordered by Date, newest first<br>
+40
View File
@@ -0,0 +1,40 @@
---
aliases:
- /doc/redirects/
- /doc/alias/
- /doc/aliases/
date: 2013-07-09
menu:
main:
parent: extras
next: /extras/builders
prev: /taxonomies/ordering
title: Aliases
weight: 10
---
For people migrating existing published content to Hugo there's a good chance
you need a mechanism to handle redirecting old URLs.
Luckily, this can be handled easily with aliases in Hugo.
## Example
**content/posts/my-awesome-blog-post.md**
---
aliases:
- /posts/my-original-url/
- /2010/even-earlier-url.html
---
Now when you go to any of the aliases locations they
will redirect to the page.
## Important Behaviors
1. *Hugo makes no assumptions about aliases. They also don't change based
on your UglyUrls setting. You need to provide absolute path to your webroot and the
complete filename or directory.*
2. *Aliases are rendered prior to any content and will be overwritten by
any content with the same location.*
+60
View File
@@ -0,0 +1,60 @@
---
date: 2014-05-26
linktitle: Builders
menu:
main:
parent: extras
next: /extras/comments
prev: /extras/aliases
title: Hugo Builders
weight: 12
---
Hugo provides the functionality to quickly get a site, theme or page
started.
## New Site
Want to get a site built quickly?
hugo new site /path/to/site
Hugo will create all the needed directories and files to get started
quickly.
Hugo will only touch the files and create the directories (in the right
places), [configuration](/overview/configuration) and content are up to
you... but luckily we have builders for content (see below).
## New Theme
Want to design a new theme?
hugo new theme `THEME_NAME`
Run from your working directory, this will create a new theme with all
the needed files in your themes directory. Hugo will provide you with a
license and theme.toml file with most of the work done for you.
Follow the [Theme Creation Guide](/themes/creation) once the builder is
done.
## New Content
You will use this builder the most of all. Every time you want to create
a new piece of content, the content builder will get you started right.
Leveraging [content archetypes](/content/archetypes) the content builder
will not only insert the current date and appropriate metadata, but it
will pre-populate values based on the content type.
hugo new relative/path/to/content
This assumes it is being run from your working directory and the content
path starts from your content directory.
I typically keep two different terminals open, one to run `hugo server
--watch`, and another to use the builders to create new content.
+99
View File
@@ -0,0 +1,99 @@
---
date: 2014-05-26
linktitle: Comments
menu:
main:
parent: extras
next: /extras/livereload
prev: /extras/builders
title: Comments in Hugo
weight: 14
---
As Hugo is a static site generator, the content produced is static and
doesnt interact with the users. The most common interaction people ask
for is comment capability.
Hugo ships with support for [disqus](http://disqus.com), a third party
service that provides comment and community capabilities to website via
javascript.
Your theme may already support disqus, but even it if doesnt it is easy
to add.
# Disqus Support
## Adding Disqus to a template
Hugo comes with all the code you would need to include load disqus.
Simply include the following line where you want your comments to appear
{{ template "_internal/disqus.html" . }}
## Configuring Disqus
That template requires you to set a single value in your site config file, eg. config.yaml.
disqusShortname = "XYW"
Additionally you can optionally set the following in the front matter
for a given piece of content
* **disqus_identifier**
* **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.
* [Intense Debate](http://intensedebate.com/)
* [LiveFyre](http://livefyre.com/)
* [Moot](http://muut.com)
* [Kaiju](http://github.com/spf13/kaiju)
[Kaiju](http://github.com/spf13/kaiju) is a open source project started
by [spf13](http://spf13.com) (Hugos author) to bring easy and fast real
time discussions to the web.
Written using Go, Socket.io and MongoDB it is very fast and easy to
deploy.
It is in early development but shows promise.. If you have interest
please help by contributing whether via a pull request, an issue or even
just a tweet. Everything helps.
+101
View File
@@ -0,0 +1,101 @@
---
aliases:
- /extras/highlight/
date: 2013-07-01
menu:
main:
parent: extras
next: /extras/toc
prev: /extras/shortcodes
title: Syntax Highlighting
weight: 50
---
Hugo provides the ability for you to highlight source code in two different
ways &mdash; either pre-processed server side from your content, or to defer
the processing to the client side, using a JavaScript library. The advantage of
server side is that it doesnt depend on a JavaScript library and consequently
works very well when read from an rss feed. The advantage of client side is that
it doesnt cost anything when building your site and some of the highlighting
scripts available cover more languages than pygments does.
For the pre-processed approach, Highlighting is performed by an external
python based program called [pygments](http://pygments.org) and is triggered
via an embedded shortcode. If pygments is absent from the path, it will
silently simply pass the content along unhighlighted.
## Server-side
### Disclaimers
* **Warning:** Pygments is relatively slow. Expect much longer build times when using server-side highlighting.
* Languages available depends on your Pygments installation.
* Styles are inline in order to be supported in syndicated content when references
to style sheets are not carried over.
* We have sought to have the simplest interface possible, which consequently
limits configuration. An ambitious user is encouraged to extend the current
functionality to offer more customization.
* You can change appearance with config options `pygmentsstyle`(default
`"monokai"`) and `pygmentsuseclasses`(defaut `false`).
### Usage
Highlight takes exactly one required parameter of language and requires a
closing shortcode.
### Example
The example has an extra space between the “{{” and “%” characters to prevent rendering here.
{{ % highlight html %}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ % /highlight %}}
### Example Output
<span style="color: #f92672">&lt;section</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;main&quot;</span><span style="color: #f92672">&gt;</span>
<span style="color: #f92672">&lt;div&gt;</span>
<span style="color: #f92672">&lt;h1</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;title&quot;</span><span style="color: #f92672">&gt;</span>{{ .Title }}<span style="color: #f92672">&lt;/h1&gt;</span>
{{ range .Data.Pages }}
{{ .Render &quot;summary&quot;}}
{{ end }}
<span style="color: #f92672">&lt;/div&gt;</span>
<span style="color: #f92672">&lt;/section&gt;</span>
## Client-side
Alternatively, code highlighting can be done in client-side JavaScript.
Client-side syntax highlighting is very simple to add. You'll need to pick
a library and a corresponding theme. Some popular libraries are:
- [Highlight.js]
- [Rainbow]
- [Syntax Highlighter]
- [Google Prettify]
This example uses the popular [Highlight.js] library, hosted by [Yandex], a
popular Russian search engine.
In your `./layouts/chrome/` folder, depending on your specific theme, there
will be a snippet that will be included in every generated HTML page, such
as `header.html` or `header.includes.html`. Simply add:
<link rel="stylesheet" href="https://yandex.st/highlightjs/8.0/styles/default.min.css">
<script src="https://yandex.st/highlightjs/8.0/highlight.min.js"></script>
You can of course use your own copy of these files, typically in `./static/`.
[Highlight.js]: http://highlightjs.org/
[Rainbow]: http://craig.is/making/rainbows
[Syntax Highlighter]: http://alexgorbatchev.com/SyntaxHighlighter/
[Google Prettify]: https://code.google.com/p/google-code-prettify/
[Yandex]: http://yandex.ru/
Please see individual libraries documentation for how to implement the JavaScript based libraries.
+61
View File
@@ -0,0 +1,61 @@
---
date: 2014-05-26
menu:
main:
parent: extras
next: /extras/menus
prev: /extras/comments
title: Live Reload
weight: 15
---
Hugo may not be the first static site generator to utilize live reload
technology, but its the first to do it right.
The combination of Hugos insane build speed and live reload make
crafting your content pure joy. Virtually instantly after you hit save
your rebuilt content will appear in your browser.
## Using livereload
Hugo comes with livereload built in. There are no additional packages to
install. A common way to use hugo while developing a site is to have
hugo run a server and watch for changes.
hugo server --watch
This will run a full functioning web server while simultaneously
watching your file system for additions, deletions or changes within
your:
* static files
* content
* layouts
* current theme
Whenever anything changes Hugo will rebuild the site, continue to serve
the content and as soon as the build is finished it will tell the
browser and silently reload the page. Because most hugo builds are so
fast they are barely noticeable, you merely need to glance at your open
browser and you will see the change already there.
This means that keeping the site open on a second monitor (or another
half of your current monitor), allows you to see exactly what your
content looks like without even leaving your text editor.
## Disabling livereload
Live reload accomplishes this by injecting javascript into the pages it
creates that creates a web socket client to the hugo web socket server.
Awesome for development, but not something you would want to do in
production. Since many people use `hugo server --watch` in production to
instantly display any updated content, weve made it easy to disable the
live reload functionality.
hugo server --watch --disableLiveReload
+178
View File
@@ -0,0 +1,178 @@
---
date: 2014-05-14T02:36:37Z
menu:
main:
parent: extras
next: /extras/permalinks
prev: /extras/livereload
title: Menus
weight: 20
---
Hugo has a simple yet powerful menu system that permits content to be
placed in menus with a good degree of control without a lot of work.
Some of the features of Hugo Menus:
* Place content in one or many menus
* Handle nested menus with unlimited depth
* Create menu entries without being attached to any content
* Distinguish active element (and active branch)
## What is a menu?
A menus is a named array of menu entries accessible on the site under
`.Site.Menus` by name. For example if I have a menu called `main` I would
access it via `.Site.Menus.main`.
A menu entry has the following properties:
* **Url** string
* **Name** string
* **Menu** string
* **Identifier** string
* **Pre** template.HTML
* **Post** template.HTML
* **Weight** int
* **Parent** string
* **Children** Menu
And the following functions:
* **HasChildren** bool
Additionally there are some relevant functions available on the page:
* **IsMenuCurrent** (menu string, menuEntry *MenuEntry ) bool
* **HasMenuCurrent** (menu string, menuEntry *MenuEntry) bool
## Adding content to menus
Hugo supports a couple of different methods of adding a piece of content
to the front matter.
### Simple
If all you need to do is add an entry to a menu, the simple form works
well.
**A single menu:**
---
menu: "main"
---
**Multiple menus:**
---
menu: ["main", "footer"]
---
### Advanced
If more control is required, then the advanced approach gives you the
control you want. All of the menu entry properties listed above are
available.
---
menu:
main:
parent: 'extras'
weight: 20
---
## Adding (non-content) entries to a menu
You can also add entries to menus that arent attached to a piece of
content. This takes place in the site wide [config file](http://hugo.spf13.com/overview/configuration).
Heres an example (in toml):
[[menu.main]]
name = "about hugo"
pre = "<i class='fa fa-heart'></i>"
weight = -110
identifier = "about"
[[menu.main]]
name = "getting started"
pre = "<i class='fa fa-road'></i>"
weight = -100
Heres 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.
The parent of an entry should be the identifier of another entry.
Identifier should be unique (within a menu).
The following order is used to determine identity Identifier > Name >
LinkTitle > Title. This means that the title will be used unless
linktitle is present, etc. In practice Name and Identifier are never
displayed and only used to structure relationships.
In this example, the top level of the menu is defined in the config file
and all content entries are attached to one of these entries via the
`parent` field.
## Rendering menus
Hugo makes no assumptions about how your rendered HTML will be
structured. Instead, it provides all of the functions you will need to be
able to build your menu however you want.
The following is an example:
<!--sidebar start-->
<aside>
<div id="sidebar" class="nav-collapse ">
<!-- sidebar menu start-->
<ul class="sidebar-menu">
{{ $currentNode := . }}
{{ range .Site.Menus.main }}
{{ if .HasChildren }}
<li class="sub-menu{{if $currentNode.HasMenuCurrent "main" . }} active{{end}}">
<a href="javascript:;" class="">
{{ .Pre }}
<span>{{ .Name }}</span>
<span class="menu-arrow arrow_carrot-right"></span>
</a>
<ul class="sub">
{{ range .Children }}
<li{{if $currentNode.IsMenuCurrent "main" . }} class="active"{{end}}><a href="{{.Url}}"> {{ .Name }} </a> </li>
{{ end }}
</ul>
{{else}}
<li>
<a class="" href="{{.Url}}">
{{ .Pre }}
<span>{{ .Name }}</span>
</a>
{{end}}
</li>
{{end}}
<li> <a href="https://github.com/spf13/hugo/issues" target="blank">Questions and Issues</a> </li>
<li> <a href="#" target="blank">Edit this Page</a> </li>
</ul>
<!-- sidebar menu end-->
</div>
</aside>
<!--sidebar end-->
+53
View File
@@ -0,0 +1,53 @@
---
aliases:
- /doc/permalinks/
date: 2013-11-18
menu:
main:
parent: extras
next: /extras/shortcodes
notoc: true
prev: /extras/menus
title: Permalinks
weight: 30
---
By default, content is laid out into the target `publishdir` (public)
namespace matching its layout within the `contentdir` hierarchy.
The `permalinks` site configuration option allows you to adjust this on a
per-section basis.
This will change where the files are written to and will change the page's
internal "canonical" location, such that template references to
`.RelPermalink` will honour the adjustments made as a result of the mappings
in this option.
For instance, if one of your sections is called `post` and you want to adjust
the canonical path to be hierarchical based on the year and month, then you
might use:
```yaml
permalinks:
post: /:year/:month/:title/
```
Only the content under `post/` will be so rewritten.
A file named `content/post/sample-entry` which contains a line
`date: 2013-11-18T19:20:00-05:00` might end up with the rendered page
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/>
+233
View File
@@ -0,0 +1,233 @@
---
aliases:
- /doc/shortcodes/
date: 2013-07-01
menu:
main:
parent: extras
next: /extras/highlighting
prev: /extras/permalinks
title: Shortcodes
weight: 40
---
Hugo uses markdown for its simple content format, however there's a lot
of things that markdown doesn't support well.
We are unwilling to accept being constrained by our simple format. Also
unacceptable is writing raw html in our markdown every time we want to include
unsupported content such as a video. To do so is in complete opposition to the
intent of using a bare bones format for our content and utilizing templates to
apply styling for display.
To avoid both of these limitations Hugo created shortcodes.
A shortcode is a simple snippet inside a content file that Hugo will render
using a predefined template. Note that shortcodes will not work in template
files - if you need a functionality like that in a template, you most likely
want a [partial template](/templates/partial) instead.
## Using a shortcode
In your content files a shortcode can be called by using '{{&#37; name parameters
%}}' respectively. Shortcodes are space delimited (parameters with spaces
can be quoted).
The first word is always the name of the shortcode. Parameters follow the name.
The format for named parameters models that of html with the format
name="value". The current implementation only supports this exact format. Extra
spaces or different quote marks will not parse properly.
Some shortcodes use or require closing shortcodes. Like HTML, the opening and closing
shortcodes match (name only), the closing being prepended with a slash.
Example of a paired shortcode:
{{ % highlight go %}} A bunch of code here {{ % /highlight %}}
## Hugo Shortcodes
Hugo ships with a set of predefined shortcodes.
### highlight
This shortcode will convert the source code provided into syntax highlighted
html. Read more on [highlighting](/extras/highlighting).
#### Usage
Highlight takes exactly one required parameter of language and requires a
closing shortcode.
#### Example
The example has an extra space between the “{{” and “%” characters to prevent rendering here.
{{ % highlight html %}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ % /highlight %}}
#### Example Output
<span style="color: #f92672">&lt;section</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;main&quot;</span><span style="color: #f92672">&gt;</span>
<span style="color: #f92672">&lt;div&gt;</span>
<span style="color: #f92672">&lt;h1</span> <span style="color: #a6e22e">id=</span><span style="color: #e6db74">&quot;title&quot;</span><span style="color: #f92672">&gt;</span>{{ .Title }}<span style="color: #f92672">&lt;/h1&gt;</span>
{{ range .Data.Pages }}
{{ .Render &quot;summary&quot;}}
{{ end }}
<span style="color: #f92672">&lt;/div&gt;</span>
<span style="color: #f92672">&lt;/section&gt;</span>
### figure
Figure is simply an extension of the image capabilities present with Markdown.
figure provides the ability to add captions, css classes, alt text, links etc.
#### Usage
figure can use the following parameters
* src
* link
* title
* caption
* attr (attribution)
* attrlink
* alt
#### Example
*Example has an extra space so Hugo doesn't actually render it*.
{{ % figure src="/media/spf13.jpg" title="Steve Francia" %}}
#### Example output
<figure>
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
## Creating your own shortcodes
To create a shortcode, place a template in the layouts/shortcodes directory. The
template name will be the name of the shortcode.
In creating a shortcode you can choose if the short code will use positional
parameters or named parameters (but not both). A good rule of thumb is that if a
short code has a single required value in the case of the youtube example below
then positional works very well. For more complex layouts with optional
parameters named parameters work best.
**Inside the template**
To access a parameter by position the .Get method can be used.
{{ .Get 0 }}
To access a parameter by name the .Get method should be utilized
{{ .Get "class" }}
With is great when the output depends on a parameter being set
{{ with .Get "class"}} class="{{.}}"{{ end }}
Get can also be used to check if a parameter has been provided. This is
most helpful when the condition depends on either one value or another...
or both.
{{ or .Get "title" | .Get "alt" | if }} alt="{{ with .Get "alt"}}{{.}}{{else}}{{.Get "title"}}{{end}}"{{ end }}
If a closing shortcode is used, the variable .Inner will be populated with all
of the content between the opening and closing shortcodes. If a closing
shortcode is required, you can check the length of .Inner and provide a warning
to the user.
## Single Positional Example: youtube
{{% youtube 09jf3ow9jfw %}}
Would load the template /layouts/shortcodes/youtube.html
<div class="embed video-player">
<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/{{ index .Params 0 }}" allowfullscreen frameborder="0">
</iframe>
</div>
This would be rendered as
<div class="embed video-player">
<iframe class="youtube-player" type="text/html"
width="640" height="385"
src="http://www.youtube.com/embed/09jf3ow9jfw"
allowfullscreen frameborder="0">
</iframe>
</div>
## Single Named Example: image with caption
*Example has an extra space so Hugo doesn't actually render it*
{{ % img src="/media/spf13.jpg" title="Steve Francia" %}}
Would load the template /layouts/shortcodes/img.html
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
<h4>{{ .Get "title" }}</h4>{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->
Would be rendered as:
<figure >
<img src="/media/spf13.jpg" />
<figcaption>
<h4>Steve Francia</h4>
</figcaption>
</figure>
## Paired Example: Highlight
*Hugo already ships with the highlight shortcode*
*Example has an extra space so Hugo doesn't actually render it*.
<html>
<body> This HTML </body>
</html>
The template for this utilizes the following code (already include in hugo)
{{ .Get 0 | highlight .Inner }}
And will be rendered as:
<div class="highlight" style="background: #272822"><pre style="line-height: 125%"><span style="color: #f92672">&lt;html&gt;</span>
<span style="color: #f92672">&lt;body&gt;</span> This HTML <span style="color: #f92672">&lt;/body&gt;</span>
<span style="color: #f92672">&lt;/html&gt;</span>
</pre></div>
Please notice that this template makes use of a hugo specific template function
called highlight which uses pygments to add the highlighting code.
More shortcode examples can be found at [spf13.com](https://github.com/spf13/spf13.com/tree/master/layouts/shortcodes)
+37
View File
@@ -0,0 +1,37 @@
---
date: 2013-07-09
menu:
main:
parent: extras
next: /extras/urls
prev: /extras/highlighting
title: Table of Contents
weight: 60
---
Hugo will automatically parse the Markdown for your content and create
a Table of Contents you can use to guide readers to the sections within
your content.
## Usage
Simply create content like you normally would with the appropriate
headers.
Hugo will take this Markdown and create a table of contents stored in the
[content variable](/layout/variables) `.TableOfContents`
## Template Example
This is example code of a [single.html template](/layout/content).
{{ template "partials/header.html" . }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ template "partials/footer.html" . }}
+45
View File
@@ -0,0 +1,45 @@
---
aliases:
- /doc/urls/
date: 2014-01-03
menu:
main:
parent: extras
next: /community/mailing-list
notoc: true
prev: /extras/toc
title: URLs
weight: 70
---
## Pretty URLs
By default Hugo will create content with 'pretty' URLs. For example
content created at /content/extras/urls.md will be rendered at
/content/extras/urls/index.html and accessible at /content/extras/urls. No
no standard server side configuration is required for these pretty urls to
work.
If you would like to have ugly URLs, you are in luck. Hugo supports the
ability to create your entire site with ugly URLs. Simply use the
`--uglyurls=true` flag on the command line.
If you want a specific piece of content to have an exact URL, you can
specify this in the front matter under the url key. See [Content
Organization](/content/organization/) for more details.
## Canonicalization
By default, all relative URLs encountered in the input will be canonicalized
using `baseurl`, so that a link `/css/foo.css` becomes
`http://yoursite.example.com/css/foo.css`.
Setting `canonifyurls` to `false` will prevent this canonicalization.
Benefits of canonicalization include fixing all URLs to be absolute, which may
aid with some parsing tasks. Note though that all real browsers handle this
client-side without issues.
Benefits of non-canonicalization include being able to have resource inclusion
be scheme-relative, so that http vs https can be decided based on how this
page was retrieved.
@@ -1,16 +1,21 @@
{
"title": "License",
"Pubdate": "2013-07-01"
}
---
aliases:
- /doc/license/
- /license/
- /meta/license/
date: 2013-07-01
menu:
main:
parent: about
title: License
weight: 50
---
Hugo is released under the Simple Public License.
## Simple Public License (SimPL-2.0)
Simple Public License (SimPL-2.0)
=================================
Preamble
--------
### Preamble
This Simple Public License 2.0 (SimPL-2.0 for short) is a plain language
implementation of GPL 2.0. The words are different, but the goal is the
@@ -19,8 +24,7 @@ software. If anyone wonders about the meaning of the SimPL, they should
interpret it as consistent with GPL 2.0.
Simple Public License (SimPL) 2.0
=================================
## Simple Public License (SimPL) 2.0
The SimPL applies to the software's source and object code and comes
with any rights that I have in it (other than trademarks). You agree to
@@ -65,8 +69,7 @@ automatically if:
- Anyone prevents you from distributing the software under the terms
of the SimPL.
License for the License
-----------------------
## License for the License
You may do anything that you want with the SimPL text; it's a license
form to use in any way that you find helpful. To avoid confusion,
+139
View File
@@ -0,0 +1,139 @@
---
aliases:
- /doc/release-notes/
- /meta/release-notes/
date: 2013-07-01
menu:
main:
parent: about
title: Release Notes
weight: 10
---
## **0.12.0** Sept 1, 2014
A lot has happened since Hugo v0.11.0 was released. Most of the work has been
focused on polishing the theme engine and adding critical functionality to the
templates.
This release represents over 90 code commits from 28 different contributors.
* 10 [new themes](https://github.com/spf13/hugoThemes) created by the community
* Fully themable [Partials](/templates/partials)
* [404 template](/templates/404/) support in themes
* [Shortcode](/extras/shortcodes/) support in themes
* [Views](/templates/views/) support in themes
* Inner [shortcode](/extras/shortcodes/) content now treated as Markdown
* Support for header ids in Markdown (# Header {#myid})
* [Where](/templates/list) template function to filter lists of content, taxonomies, etc
* [GroupBy](/templates/list) & [GroupByDate](/templates/list) methods to group pages
* Taxonomy [pages list](/taxonomies/methods/) now sortable, filterable, limitable & groupable
* General cleanup to taxonomies & documentation to make it more clear and consistent
* [Showcase](/showcase/) returned and has been expanded
* Pretty links now always have trailing slashes
* [BaseUrl](/overview/configuration/) can now include a subdirectory
* Better feedback about draft & future post rendering
* A variety of improvements to [the website](http://hugo.spf13.com)
## **0.11.0** May 28, 2014
This release represents over 110 code commits from 29 different contributors.
* Considerably faster... about 3 - 4x faster on average
* [Live Reload](/extras/livereload). Hugo will automatically reload the browser when the build is complete
* Theme engine w/[Theme Repository](http://github.com/spf13/hugoThemes)
* [Menu system](/extras/menus) with support for active page
* [Builders](/extras/builders) to quickly create a new site, content or theme
* [XML sitemap](/templates/sitemap) generation
* [Integrated Disqus](/extras/comments) support
* Streamlined [template organization](/templates/overview)
* [Brand new docs site](http://hugo.spf13.com)
* Support for publishDate which allows for posts to be dated in the future
* More [sort](/content/ordering) options
* Logging support
* Much better error handling
* More informative verbose output
* Renamed Indexes > [Taxonomies](/taxonomies/overview)
* Renamed Chrome > [Partials](/templates/partials)
## **0.10.0** March 1, 2014
This release represents over 110 code commits from 29 different contributors.
* [Syntax highlighting](/extras/highlighting) powered by pygments (**slow**)
* Ability to [sort content](/content/ordering) many more ways
* Automatic [table of contents](/extras/toc) generation
* Support for unicode urls, aliases and indexes
* Configurable per-section [permalink](/extras/permalinks) pattern support
* Support for [paired shortcodes](/extras/shortcodes)
* Shipping with some [shortcodes](/extras/shortcodes) (highlight & figure)
* Adding [canonify](/extras/urls) option to keep urls relative
* A bunch of [additional template functions](/layout/functions)
* Watching very large sites now works on mac
* RSS generation improved. Limited to 50 items by default, can limit further in [template](/layout/rss)
* Boolean params now supported in [frontmatter](/content/front-matter)
* Launched website [showcase](/showcase). Show off your own hugo site!
* A bunch of [bug fixes](https://github.com/spf13/hugo/commits/master)
## **0.9.0** November 15, 2013
This release represents over 220 code commits from 22 different contributors.
* New [command based interface](/overview/usage) similar to git (hugo server -s ./ )
* Amber template support
* [Aliases](/extras/aliases) (redirects)
* Support for top level pages (in addition to homepage)
* Complete overhaul of the documentation site
* Full Windows support
* Better index support including [ordering by content weight](/content/ordering)
* Add params to site config, available in .Site.Params from templates
* Friendlier json support
* Support for html & xml content (with frontmatter support)
* Support for [summary](/content/summaries) content divider (&lt;!more>)
* HTML in [summary](/content/summaries) (when using divider)
* Added ["Minutes to Read"](/layout/variables) functionality
* Support for a custom 404 page
* Cleanup of how content organization is handled
* Loads of unit and performance tests
* Integration with travis ci
* Static directory now watched and copied on any addition or modification
* Support for relative permalinks
* Fixed watching being triggered multiple times for the same event
* Watch now ignores temp files (as created by Vim)
* Configurable number of posts on [homepage](/layout/homepage/)
* [Front matter](/content/front-matter) supports multiple types (int, string, date, float)
* Indexes can now use a default template
* Addition of truncated bool to content to determine if should show 'more' link
* Support for [linkTitles](/layout/variables)
* Better handling of most errors with directions on how to resolve
* Support for more date / time formats
* Support for go 1.2
* Support for `first` in templates
## **0.8.0** August 2, 2013
This release represents over 65 code commits from 6 different contributors.
* Added support for pretty urls (filename/index.html vs filename.html)
* Hugo supports a destination directory
* Will efficiently sync content in static to destination directory
* Cleaned up options.. now with support for short and long options
* Added support for TOML
* Added support for YAML
* Added support for Previous & Next
* Added support for indexes for the indexes
* Better Windows compatibility
* Support for series
* Adding verbose output
* Loads of bugfixes
## **0.7.0** July 4, 2013
* Hugo now includes a simple server
* First public release
## **0.6.0** July 2, 2013
* Hugo includes an example documentation site which it builds
## **0.5.0** June 25, 2013
* Hugo is quite usable and able to build spf13.com
+25
View File
@@ -0,0 +1,25 @@
---
aliases:
- /doc/roadmap/
- /meta/roadmap/
date: 2013-07-01
menu:
main:
parent: about
notoc: true
title: Hugo Roadmap
weight: 20
---
In no particular order, here is what we are working on:
* Intelligently Related Posts
* Even easier deployment to S3, SSH, GitHub, rsync
* Import from other website systems (WordPress, Jekyll)
* An interactive web based editor
* Additional themes
* Dynamic image resizing via shortcodes
* Support for additional formats
* Pagination
* Your best ideas
+68
View File
@@ -0,0 +1,68 @@
---
aliases:
- /doc/configuration/
date: 2013-07-01
linktitle: Configuration
menu:
main:
parent: getting started
next: /overview/source-directory
notoc: true
prev: /overview/usage
title: Configuring Hugo
weight: 40
---
The directory structure and templates provide the majority of the
configuration for a site. In fact a config file isn't even needed for many
websites since the defaults follow commonly used patterns.
Hugo expects to find the config file in the root of the source directory and
will look there first for a `config.toml` file. If none is present it will
then look for a `config.yaml` file, followed by a `config.json` file.
The config file is a site-wide config. The config file provides directions to
hugo on how to build the site as well as site-wide parameters and menus.
## Examples
The following is an example of a typical yaml config file:
---
baseurl: "http://yoursite.example.com/"
...
The following is an example of a toml config file with some of the default values:
contentdir = "content"
layoutdir = "layouts"
publishdir = "public"
builddrafts = false
baseurl = "http://yoursite.example.com/"
canonifyurls = true
[indexes]
category = "categories"
tag = "tags"
Here is a yaml configuration file which sets a few more options
---
baseurl: "http://yoursite.example.com/"
title: "Yoyodyne Widget Blogging"
permalinks:
post: /:year/:month/:title/
params:
Subtitle: "Spinning the cogs in the widgets"
AuthorName: "John Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
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.
+65
View File
@@ -0,0 +1,65 @@
---
aliases:
- /doc/installing/
date: 2013-07-01
menu:
main:
parent: getting started
next: /overview/usage
prev: /overview/quickstart
title: Installing Hugo
weight: 20
---
Hugo is written in Go with support for Windows, Linux, FreeBSD and OS&nbsp;X.
The latest release can be found at [Hugo Releases](https://github.com/spf13/hugo/releases).
We currently build for Windows, Linux, FreeBSD and OS&nbsp;X for x64
and i386 architectures.
## Installing Hugo (binary)
Installation is very easy. Simply download the appropriate version for your
platform from [Hugo Releases](https://github.com/spf13/hugo/releases).
Once downloaded it can be run from anywhere. You don't need to install
it into a global location. This works well for shared hosts and other systems
where you don't have a privileged account.
Ideally you should install it somewhere in your path for easy use. `/usr/local/bin`
is the most probable location.
### Installing Pygments (optional)
The Hugo executable has one *optional* external dependency for source code highlighting (Pygments).
If you want to have source code highlighting using the [highlight shortcode](/extras/highlighting),
you need to install the Python-based Pygments program. The procedure is outlined on the [Pygments home page](http://pygments.org).
## Upgrading Hugo
Upgrading Hugo is as easy as downloading and replacing the executable youve
placed in your path.
## Installing from source
### Dependencies
* Git
* Go 1.1+
* Mercurial
* Bazaar
### Get directly from GitHub:
go get -v github.com/spf13/hugo
### Building Hugo
cd /path/to/hugo
go build -o hugo main.go
mv hugo /usr/local/bin/
## Contributing
Please see the [contributing guide](/doc/contributing).
+124
View File
@@ -0,0 +1,124 @@
---
date: 2013-07-01
linktitle: Introduction
menu:
main:
parent: getting started
next: /overview/quickstart
title: Introduction to Hugo
weight: 5
---
## What is Hugo?
Hugo is a general-purpose website framework. Technically speaking, Hugo is
a static site generator. This means that unlike systems like WordPress,
Ghost and Drupal which run on your web server expensively building a page
every time a visitor requests one, Hugo does the building when you create
your content. Since websites are viewed far more often then they are
edited, Hugo is optimized for website viewing while providing a great
writing experience.
Sites built with Hugo are extremely fast and very secure. Hugo sites can
be hosted anywhere including Heroku, GoDaddy, GitHub pages, S3
and Cloudfront and work well with CDNs. Hugo sites run without dependencies
on expensive run times like Ruby, Python or PHP and without dependencies
on any databases.
We think of Hugo as the ideal website creation tool. With nearly instant
build times and the ability to rebuild whenever a change is made, Hugo
provides a very fast feedback loop. This is essential when you are
designing websites, but also very useful when creating content.
## What does Hugo do?
In technical terms Hugo takes a source directory of Markdown files and
templates and uses these as input to create a complete website.
Hugo boasts the following features:
### General
* Extremely fast build times (~1&nbsp;ms per page)
* Completely cross platform: Runs on Mac OS&nbsp;X, Linux and Windows
* Easy [installation](/overview/installing)
* Render changes [on the fly](/overview/usage) with [live reload](/extras/livereload) as you develop
* Complete theme support
* Host your site anywhere
### Organization
* Straightforward [organization](/content/organization)
* Support for [website sections](/content/sections)
* Completely customizable [URLs](/extras/urls)
* 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
* [Pretty URLs](/extras/urls) support
* [Permalink](/extras/permalinks) pattern support
* [Aliases](/extras/aliases) (redirects)
### Content
* Content written in [Markdown](/content/example)
* Support for TOML, YAML and JSON metadata in [frontmatter](/content/front-matter)
* Completely [customizable homepage](/layout/homepage)
* Support for multiple [content types](/content/types)
* Automatic and user defined [summaries](/content/summaries)
* [shortcodes](/extras/shortcodes) to enable rich content inside of Markdown
* ["Minutes to Read"](/layout/variables) functionality
* ["Wordcount"](/layout/variables) functionality
### Additional Features
* Integrated Disqus comment support
* Automatic [RSS](/layout/rss) creation
* Support for Go and [Amber](https://github.com/eknkc/amber) templates
* Syntax [highlighting](/extras/highlighting) powered by pygments
See what's coming next in the [roadmap](/meta/roadmap)
## Who should use Hugo?
Hugo is for people that prefer writing in a text editor over
a browser.
Hugo is for people who want to hand code their own website without
worrying about setting up complicated runtimes, dependencies and
databases.
Hugo is for people building a blog, company site, portfolio, tumblog,
documentation, single page site or a site with thousands of
pages.
## Why did you write Hugo?
I wrote Hugo ultimately for a few reasons. First I was disappointed with
WordPress, my then website solution. It rendered slowly. I couldn't create
content as efficiently as I wanted to and needed to be online to write
posts. The constant security updates and the horror stories of people's
hacked blogs. I hated how content was written in HTML instead of the much
simpler Markdown. Overall I felt like it got in my way more than it helped
my from writing great content.
I looked at existing static site generators like Jekyll, Middleman and nanoc.
All had complicated dependencies to install and took far longer to render
my blog with hundreds of posts than I felt was acceptable. I wanted
a framework to be able to get rapid feedback while making changes to the
templates and the 5+-minute render times was just too slow. In general
they were also very blog minded and didn't have the ability to have
different content types and flexible URLs.
I wanted to develop a fast and full featured website framework without
dependencies. The Go language seemed to have all of the features I needed
in a language. I began developing Hugo in Go and fell in love with the
language. I hope you will enjoy using (and contributing to) Hugo as much
as I have writing it.
## Next Steps
* [Install Hugo](/overview/installing)
* [Quick start](/overview/quickstart)
* [Join the Mailing List](/community/mailing-list)
* [Star us on GitHub](http://github.com/spf13/hugo)
+159
View File
@@ -0,0 +1,159 @@
---
date: 2013-07-01
linktitle: Quickstart
menu:
main:
parent: getting started
next: /overview/installing
prev: /overview/introduction
title: Hugo Quickstart Guide
weight: 10
---
_This quickstart depends on features introduced in hugo v0.11. If you
have an earlier version of hugo you will need to [upgrade](/overview/installing/) before
proceeding._
## Step 1. Install Hugo
Go to [Hugo Releases](https://github.com/spf13/hugo/releases) and download the
appropriate version for your os and architecture.
Save it somewhere specific as we will be using it in the next step.
More complete instructions are available at [Installing Hugo](/overview/installing/)
## Step 2. Have Hugo Create a site for you
Hugo has the ability to create a skeleton site.
hugo new site /path/to/site
For the rest of the operations we will be executing all commands from within the site directory
cd /path/to/site
The new site will have the following structure
▸ archetypes/
▸ content/
▸ layouts/
▸ static/
config.toml
Currently the site doesnt have any content, nor is it configured.
## Step 3. Create Some Content
Hugo also has the ability to create content for you.
hugo new about.md
A new file is now created in `content/` with the following contents
+++
draft = true
title = "about"
date = 2014-05-20T10:04:31Z
+++
Notice the date is automatically set to the moment you created the content.
Place some content in this file below the `+++` in the Markdown format.
For example you could put this
## A headline
Some Content
For fun, lets create another piece of content and place some Markdown in it as well.
hugo new post/first.md
The new file is located at `content/post/first.md`
We still lack any templates to tell us how to display the content.
## Step 4. Install some themes
Hugo has rich theme support and a growing set of themes to choose from.
git clone --recursive https://github.com/spf13/hugoThemes themes
## Step 5. Run Hugo
Hugo contains its own high performance web server. Simply run `hugo
server` and Hugo will find an available port and run a server with
your content:
hugo server --theme=hyde --buildDrafts
2 pages created
0 tags created
0 categories created
in 5 ms
Serving pages from exampleHugoSite/public
Web Server is available at http://localhost:1313
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.
To learn about what other options hugo has, run:
hugo help
To learn about the server options:
hugo help server
## Step 6. Edit Content
Not only can Hugo run a server, but it can also watch your files for
changes and automatically rebuild your site. Hugo will then
communicate with your browser and automatically reload any open page.
This even works in mobile browsers.
Stop the Hugo process by hitting ctrl+c. Then run the following:
hugo server --theme=hyde --buildDrafts --watch
2 pages created
0 tags created
0 categories created
in 5 ms
Watching for changes in exampleHugoSite/content
Serving pages from exampleHugoSite/public
Web Server is available at http://localhost:1313
Press ctrl+c to stop
Open your [favorite editor](http://vim.spf13.com), edit and save your content and watch as Hugo rebuilds and reloads automatically.
Its especially productive to leave a browser open on a second monitor
and just glance at it whenever you save. You dont even need to tab to
your browser. Hugo is so fast that the new site will be there before
you can look at the browser in most cases.
Change and save this file. Notice what happened in your terminal.
Change detected, rebuilding site
2 pages created
0 tags created
0 categories created
in 5 ms
## Step 7. Have fun
The best way to learn something is to play with it.
Things to try:
* Add a [new content file](/content/organization/)
* Create a [new section](/content/sections/)
* Modify [a template](/layout/templates/)
* Create content with [TOML front matter](/content/front-matter/)
* Define your own field in [front matter](/content/front-matter/)
* Display that [field in the template](/layout/variables/)
* Create a [new content type](/content/types/)
@@ -1,18 +1,48 @@
{
"title": "Source Directory Organization",
"Pubdate": "2013-07-01"
}
---
aliases:
- /doc/source-directory/
date: 2013-07-01
menu:
main:
parent: getting started
next: /content/organization
notoc: true
prev: /overview/configuration
title: Source Organization
weight: 50
---
Hugo takes a single directory and uses it as the input for creating a complete website.
Hugo takes a single directory and uses it as the input for creating a complete
website.
Hugo has a very small amount of configuration, while remaining highly customizable.
It accomplishes by assuming that you will only provide templates with the intent of
using them.
The top level of a source directory will typically have the following elements:
▸ archetypes/
▸ content/
▸ layouts/
▸ static/
▸ themes/
config.toml
Learn more about the different directories and what their purpose is
* [config](/overview/configuration)
* [archetypes](/content/archetypes)
* [content](/content/organization)
* [layouts](/layout/overview)
* [static](/themes/creation#toc_4)
* [themes](/themes/overview)
## Example
An example directory may look like:
.
├── config.json
├── config.toml
├── archetypes
| └── default.md
├── content
| ├── post
| | ├── firstpost.md
@@ -21,10 +51,13 @@ An example directory may look like:
| | ├── first.md
| | └── second.md
├── layouts
| ├── chrome
| ├── _default
| | ├── single.html
| | └── list.html
| ├── partials
| | ├── header.html
| | └── footer.html
| ├── indexes
| ├── taxonomies
| | ├── category.html
| | ├── post.html
| | ├── quote.html
@@ -42,13 +75,16 @@ An example directory may look like:
| | ├── vimeo.html
| | └── youtube.html
| ├── index.html
| └── rss.xml
── public
| └── sitemap.xml
── themes
| ├── hyde
| └── doc
└── static
├── css
└── js
This directory structure tells us a lot about this site:
1. the website intends to have two different types of content, posts and quotes.
2. It will also apply two different indexes to that content, categories and tags.
3. It will be displaying content in 3 different views, a list, a summary and a full page view.
Included with the repository is this example site ready to be rendered.
+89
View File
@@ -0,0 +1,89 @@
---
aliases:
- /doc/usage/
date: 2013-07-01
menu:
main:
parent: getting started
next: /overview/configuration
notoc: true
prev: /overview/installing
title: Using Hugo
weight: 30
---
Make sure either hugo is in your path or provide a path to it.
$ hugo help
A Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.
Complete documentation is available at http://hugo.spf13.com
Usage:
hugo [flags]
hugo [command]
Available Commands:
server :: Hugo runs its own a webserver to render the files
version :: Print the version number of Hugo
check :: Check content in the source directory
benchmark :: Benchmark hugo by building a site a number of times
new [path] :: Create new content for your site
help [command] :: Help about any command
Available Flags:
-b, --baseUrl="": hostname (and path) to the root eg. http://spf13.com/
-D, --buildDrafts=false: build content marked as draft
-F, --buildFuture=false: build content with PublishDate in the future
--config="": config file (default is path/config.yaml|json|toml)
-d, --destination="": filesystem path to write files to
--disableRSS=false: Do not build RSS files
--disableSitemap=false: Do not build Sitemap file
--log=false: Enable Logging
--logFile="": Log File path (if set, logging enabled automatically)
-s, --source="": filesystem path to read files relative from
--stepAnalysis=false: display memory and timing of different steps of the program
-t, --theme="": theme to use (located in /themes/THEMENAME/)
--uglyUrls=false: if true, use /filename.html instead of /filename/
-v, --verbose=false: verbose output
--verboseLog=false: verbose logging
-w, --watch=false: watch filesystem for changes and recreate as needed
Use "hugo help [command]" for more information about that command.
## Common Usage Example:
The most common use is probably to run hugo with your current
directory being the input directory.
$ hugo
> X pages created
in 8 ms
If you are working on things and want to see the changes
immediately, tell Hugo to watch for changes.
Hugo will watch the filesystem for changes, rebuild your site as soon as a file
is saved.
$ hugo -s ~/mysite --watch
28 pages created
in 18 ms
Watching for changes in /Users/spf13/Code/hugo/docs/content
Press ctrl+c to stop
Hugo can even run a server and create your site at the same time! Hugo
implements [live reload](/extras/livereload) technology to automatically reload any open pages in
all browsers (including mobile).
$ hugo server -ws ~/mysite
Watching for changes in /Users/spf13/Code/hugo/docs/content
Web Server is available at http://localhost:1313
Press ctrl+c to stop
28 pages created
0 tags created
in 18 ms
+15
View File
@@ -0,0 +1,15 @@
---
date: 2014-02-03T20:00:00Z
description: Ant Zucaro's Blog
license: GPL
licenseLink: ""
sitelink: http://antzucaro.com
sourceLink: http://github.com/antzucaro/az.com
tags:
- personal
- blog
- foundation
thumbnail: /img/antzucaro-tn.jpg
title: Ant Zucaro
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-01-22T07:32:00Z
description: ""
license: CC-BY-SA
licenseLink: ""
sitelink: http://andrewcodispoti.com
sourceLink: https://gitlab.com/acodispo/andrewcodispoti-com
tags:
- personal
- bootstrap
thumbnail: /img/asc-tn.jpg
title: Andrew S Codispoti
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T09:18:19-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://carlorat.me/
sourceLink: https://bitbucket.org/carloratm/carlorat.me/src
tags:
- personal
- blog
thumbnail: /img/carlorat-tn.jpg
title: carlorat
---
@@ -0,0 +1,14 @@
---
date: 2013-10-02T07:32:00Z
description: ""
license: CC-SA
licenseLink: ""
sitelink: http://chimeraarts.org
sourceLink: https://github.com/chimera/chimeraarts.org
tags:
- company
- bootstrap
thumbnail: /img/chimera-tn.jpg
title: Chimera Art Space
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T11:20:02-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://www.chingli.com/
sourceLink: ""
tags:
- personal
- blog
thumbnail: /img/chingli-tn.jpg
title: chingli
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-03-27T09:45:00Z
description: CloudShark Appliance homepage and documentation
license: ""
licenseLink: ""
sitelink: https://appliance.cloudshark.org
tags:
- company
- documentation
- foundation
thumbnail: /img/cloudshark-tn.jpg
title: CloudShark
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T10:55:23-04:00
description: ""
license: MIT
licenseLink: ""
sitelink: http://danmux.com/
sourceLink: https://github.com/danmux/danmux-hugo
tags:
- personal
- blog
thumbnail: /img/danmux-tn.jpg
title: Danmux
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T11:31:02-04:00
description: ""
license: ""
licenseLink: ""
sitelink: https://devmonk.com/
sourceLink: https://github.com/peteraba/devmonk.com
tags:
- educational
- video
thumbnail: /img/devmonk-tn.jpg
title: devmonk
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-25T18:30:40-04:00
description: the website developed for the Hackmeeting 2014, the italian meeting of the digital countercultures held this year in Bologna
license: Unknown
licenseLink: ""
sitelink: http://it.hackmeeting.org/
sourceLink: https://git.autistici.org/void/hackit14
tags:
- foundation5
- conference
thumbnail: /img/hackmeeting-tn.jpg
title: hackmeeting
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-03-09T06:00:00Z
description: ""
license: MIT
licenseLink: ""
sitelink: http://heyitsalex.net
sourceLink: https://github.com/alexandre-normand/alexandre-normand
tags:
- personal
- blog
thumbnail: /img/heyitsalex-tn.jpg
title: Hey, it's Alex
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2013-07-01T07:32:00Z
description: This site
license: Simpl
licenseLink: ""
sitelink: http://hugo.spf13.com
sourceLink: http://github.com/spf13/hugo/docs
tags:
- documentation
- bootstrap
thumbnail: /img/hugo-tn.jpg
title: Hugo
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2013-11-02T07:32:00Z
description: ""
license: MIT
licenseLink: ""
sitelink: http://ifup.org
sourceLink: http://www.ifup.org
tags:
- personal
- blog
thumbnail: /img/ifup-tn.jpg
title: ifup
---
+15
View File
@@ -0,0 +1,15 @@
---
date: 2014-02-27T20:35:00Z
description: Kieran Healy's Website
license: ""
licenseLink: ""
sitelink: http://kieranhealy.org
sourceLink: http://github.com/kjhealy/kieranhealy.hugo
tags:
- personal
- blog
- academic
thumbnail: /img/kjhealy-tn.jpg
title: Kieran Healy
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-25T18:59:30-04:00
description: Alexandr Morozov
license: ""
licenseLink: ""
sitelink: http://lk4d4.darth.io/
sourceLink: https://github.com/LK4D4/lk4d4.darth.io
tags:
- personal
- blog
thumbnail: /img/lk4d4-tn.jpg
title: lk4d4.darth.io
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T11:47:11-04:00
description: ""
license: Simpl-2.0
licenseLink: ""
sitelink: http://michaelwhatcott.com/
sourceLink: https://bitbucket.org/mdwhatcott/michaelwhatcott.com-boilerplate/src
tags:
- personal
- blog
thumbnail: /img/michaelwhatcott-tn.jpg
title: michaelwhatcott
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T09:07:59-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://dsk.mn/
sourceLink: https://github.com/minodisk/blog
tags:
- personal
- blog
thumbnail: /img/minodisk-tn.jpg
title: minodisk
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T12:15:48-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://blog.nickoneill.name/
sourceLink: https://github.com/nickoneill/blog.nickoneill.name
tags:
- personal
- blog
thumbnail: /img/nickoneill-tn.jpg
title: authenticgeek
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T09:47:00-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://blog.ninya.io/
sourceLink: https://github.com/ninya-io/ninya-io.github.io/tree/dev
tags:
- project
- blog
thumbnail: /img/ninya-tn.jpg
title: ninya.io
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-21T12:21:18-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://npf.io
sourceLink: https://github.com/natefinch/npf
tags:
- personal
- blog
thumbnail: /img/npf-tn.jpg
title: npf.io
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T11:30:57-04:00
description: ""
license: ""
licenseLink: ""
sitelink: https://peteraba.com/
sourceLink: https://github.com/peteraba/peteraba.com
tags:
- personal
- blog
thumbnail: /img/peteraba-tn.jpg
title: peteraba
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2013-07-01T07:32:00Z
description: The first Hugo powered website.
license: MIT
licenseLink: ""
sitelink: http://spf13.com
sourceLink: http://github.com/spf13/spf13.com
tags:
- personal
- blog
thumbnail: /img/spf13-tn.jpg
title: spf13.com
---
+13
View File
@@ -0,0 +1,13 @@
---
date: 2014-05-22T19:54:00Z
description: Tech Coaching site
license: ""
licenseLink: ""
sitelink: http://techmadeplain.com
tags:
- personal
- blog
thumbnail: /img/techmadeplain-tn.jpg
title: Tech Made Plain
---
+13
View File
@@ -0,0 +1,13 @@
---
date: 2014-08-26T09:34:42-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://tendermint.com/
sourceLink: https://github.com/tendermint/tendermint.github.io
tags:
- project
thumbnail: /img/tendermint-tn.jpg
title: tendermint
---
+13
View File
@@ -0,0 +1,13 @@
---
date: 2014-08-26T14:12:55-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://www.philosophy.ucsb.edu/
sourceLink: https://github.com/grumble/philweb
tags:
- educatation
thumbnail: /img/ucsb-tn.jpg
title: ucsb
---
+14
View File
@@ -0,0 +1,14 @@
---
date: 2014-08-26T12:09:39-04:00
description: ""
license: ""
licenseLink: ""
sitelink: http://vurt.co.uk/
sourceLink: https://github.com/gilesp/vurtcouk
tags:
- personal
- blog
thumbnail: /img/vurt.co-tn.jpg
title: vurt.co.uk
---
+15
View File
@@ -0,0 +1,15 @@
---
date: 2014-04-07T10:45:00Z
description: Community project of YSlow rules translations
license: MIT License
licenseLink: https://raw.github.com/checkmyws/yslow-rules/master/LICENSE
sitelink: http://checkmyws.github.io/yslow-rules/
sourceLink: https://github.com/checkmyws/yslow-rules
tags:
- community
- documentation
- translation
thumbnail: /img/yslow-rules.jpg
title: YSlow Rules
---
+119
View File
@@ -0,0 +1,119 @@
---
aliases:
- /indexes/displaying/
date: 2013-07-01
linktitle: Displaying
menu:
main:
parent: taxonomy
next: /taxonomies/templates
prev: /taxonomies/usage
title: Displaying Taxonomies
weight: 20
---
There are four common ways you can display the data in your
taxonomies in addition to the automatic taxonomy pages created by hugo
using the [list templates](/templates/list).
1. For a given piece of content you can list the terms attached
2. For a given piece of content you can list other content with the same
term
3. You can list all terms for a taxonomy
4. You can list all taxonomies (with their terms)
## 1. Displaying taxonomy terms assigned to this content
Within your content templates you may wish to display
the taxonomies that that piece of content is assigned to.
Because we are leveraging the front matter system to
define taxonomies for content, the taxonomies assigned to
each content piece are located in the usual place
(.Params.`plural`)
### Example
<ul id="tags">
{{ range .Params.tags }}
<li><a href="tags/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
## 2. Listing content with the same taxonomy term
First you may be asking why you would use this. If you are using a
taxonomy for something like a series of posts, this is exactly how you
would do it. Its also an quick and dirty way to show some related
content.
### Example
<ul>
{{ range .Site.Taxonomies.series.golang }}
<li><a href="{{ .Url }}">{{ .Name }}</a></li>
{{ end }}
</ul>
## 3. Listing all content in a given taxonomy
This would be very useful in a sidebar as “featured content”. You could
even have different sections of “featured content” by assigning
different terms to the content.
### Example
<section id="menu">
<ul>
{{ range $key, $taxonomy := .Site.Taxonomies.featured }}
<li> {{ $key }} </li>
<ul>
{{ range $taxonomy.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</section>
## 4. Rendering a Site's Taxonomies
If you wish to display the list of all keys for an taxonomy you can find retrieve
them from the `.Site` variable which is available on every page.
This may take the form of a tag cloud, a menu or simply a list.
The following example displays all tag keys:
### Example
<ul id="all-tags">
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
<li><a href="/tags/{{ $name | urlize }}">{{ $name }}</a></li>
{{ end }}
</ul>
### Complete Example
This example will list all taxonomies, each of their keys and all the content assigned to each key.
<section>
<ul>
{{ range $taxonomyname, $taxonomy := .Site.Taxonomies }}
<li><a href="/{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a>
<ul>
{{ range $key, $value := $taxonomy }}
<li> {{ $key }} </li>
<ul>
{{ range $value.Pages }}
<li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
{{ end }}
</ul>
{{ end }}
</ul>
</li>
{{ end }}
</ul>
</section>
+54
View File
@@ -0,0 +1,54 @@
---
date: 2014-05-26
linktitle: Structure & Methods
menu:
main:
parent: taxonomy
next: /extras/aliases
prev: /taxonomies/ordering
title: Using Taxonomies
weight: 75
---
Hugo makes a set of values and methods available on the various Taxonomy structures.
## Taxonomy Methods
A Taxonomy is a `map[string]WeightedPages`.
**.Get(term)** Returns the WeightedPages for a term. <br>
**.Count(term)** The number of pieces of content assigned to this term.<br>
**.Alphabetical** Returns an OrderedTaxonomy (slice) ordered by Term. <br>
**.ByCount** Returns an OrderedTaxonomy (slice) ordered by number of entries. <br>
## OrderedTaxonomy
Since Maps are unordered, an OrderedTaxonomy is a special structure that has a defined order.
[]struct {
Name string
WeightedPages WeightedPages
}
Each element of the slice has:
**.Term** The Term used.<br>
**.WeightedPages** A slice of Weighted Pages.<br>
**.Count** The number of pieces of content assigned to this term.<br>
**.Pages** All Pages assigned to this term. All [list methods](/templates/list/) are available to this.<br>
## WeightedPages
WeightedPages is simply a slice of WeightedPage.
type WeightedPages []WeightedPage
**.Count(term)** The number of pieces of content assigned to this term.<br>
**.Pages** Returns a slice of pages, which then can be ordered using any of the [list methods](/templates/list/). <br>
+77
View File
@@ -0,0 +1,77 @@
---
aliases:
- /indexes/ordering/
date: 2013-07-01
linktitle: Ordering
menu:
main:
identifier: Ordering Taxonomies
parent: taxonomy
next: /taxonomies/functions
prev: /taxonomies/templates
title: Ordering Taxonomies
weight: 60
---
Hugo provides the ability to both:
1. Order the way the keys for an taxonomy are displayed
2. Order the way taxonomyed content appears
## Ordering Taxonomies
Taxonomies can be ordered by either alphabetical key or by the number of content pieces assigned to that key.
### Order Alphabetically Example:
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.Alphabetical }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
### Order by Popularity Example:
<ul>
{{ $data := .Data }}
{{ range $key, $value := .Data.Taxonomy.ByCount }}
<li><a href="{{ $data.Plural }}/{{ $value.Name | urlize }}"> {{ $value.Name }} </a> {{ $value.Count }} </li>
{{ end }}
</ul>
[See Also Taxonomy Lists](/taxonomies/lists/)
## Ordering Content within Taxonomies
Hugo uses both **Date** and **Weight** to order content within taxonomies.
Each piece of content in Hugo can optionally be assigned a date.
It can also be assigned a weight for each taxonomy it is assigned to.
When iterating over content within taxonomies the default sort is first by weight then by date. This means that if the weights for two pieces of content are the same, than the more recent content will be displayed first. The default weight for any piece of content is 0.
### Assigning Weight
Content can be assigned weight for each taxonomy that it's assigned to.
+++
tags = [ "a", "b", "c" ]
tags_weight = 22
categories = ["d"]
title = "foo"
categories_weight = 44
+++
Front Matter with weighted tags and categories
The convention is `taxonomyname_weight`.
In the above example, this piece of content has a weight of 22 which applies to the sorting when rendering the pages assigned to the "a", "b" and "c" values of the 'tag' taxonomy.
It has also been assigned the weight of 44 when rendering the 'd' category.
With this the same piece of content can appear in different positions in different taxonomies.
Currently taxonomies only support the default ordering of content which is weight -> date.
+92
View File
@@ -0,0 +1,92 @@
---
aliases:
- /indexes/overview/
- /doc/indexes/
- /extras/indexes
date: 2013-07-01
linktitle: Overview
menu:
main:
identifier: taxonomy overview
parent: taxonomy
next: /taxonomies/usage
prev: /templates/404
title: Taxonomy Overview
weight: 10
---
Hugo includes support for user defined groupings of content called
taxonomies. Taxonomies give us a way to classify our content so we can
demonstrate relationships in a variety of logical ways.
The default taxonomies for Hugo are tags and categories. These
taxonomies are common to many website systems (WordPress, Drupal,
Jekyll). Unlike all of those systems, Hugo makes it trivial to customize
the taxonomies you will be using for your site however you wish. Another
good use for taxonomies is to group a set of posts into a series. Other
common uses would include categories, tags, groups, series and many
more.
When taxonomies are used (and templates are provided) Hugo will
automatically create pages listing all of the taxonomies, their terms
and all of the content attached to those terms.
## Definitions
**Taxonomy:** A categorization that can be used to classify content
**Term:** A key within that taxonomy
**Value:** A piece of content assigned to that Term
## Example
For example if I was writing about movies I may want the following
taxonomies:
* Actors
* Directors
* Studios
* Genre
* Year
* Awards
I would then specify in each movies front-matter the specific terms for
each of those taxonomies. Hugo would then automatically create pages for
each Actor, Director, Studio, Genre, Year and Award listing all of the
Movies that matched that specific Actor, Director, etc.
### Taxonomy Organization
Lets use an example to demonstrate the different labels in action.
From the perspective of the taxonomy it could be visualized as:
Actor <- Taxonomy
Bruce Willis <- Term
The Six Sense <- Content
Unbreakable <- Content
Moonrise Kingdom <- Content
Samuel L. Jackson <- Term
Unbreakable <- Content
The Avengers <- Content
xXx <- Content
From the perspective of the content if would appear differently, though
the data and labels used are the same:
Unbreakable <- Content
Actors <- Taxonomy
Bruce Willis <- Term
Samuel L. Jackson <- Term
Director <- Taxonomy
M. Night Shyamalan <- Term
...
Moonrise Kingdom <- Content
Actors <- Taxonomy
Bruce Willis <- Term
Bill Murray <- Term
Director <- Taxonomy
Wes Anderson <- Term
...
+25
View File
@@ -0,0 +1,25 @@
---
aliases:
- /indexes/templates/
date: 2013-07-01
linktitle: Templates
menu:
main:
parent: taxonomy
next: /taxonomies/ordering
prev: /templates/displaying
title: Taxonomy Templates
weight: 30
---
There are two different templates that the use of taxonomies will require you to provide.
Both templates are covered in detail in the templates section.
A [list template](/templates/list/) is any template that will be used to render multiple pieces of
content in a single html page. This template will be used to generate
all the automatically created taxonomy pages.
A [taxonomy terms template](/templates/terms/) is a template used to
generate the list of terms for a given template.
+60
View File
@@ -0,0 +1,60 @@
---
date: 2014-05-26
linktitle: Usage
menu:
main:
parent: taxonomy
next: /taxonomies/displaying
prev: /taxonomies/overview
title: Using Taxonomies
weight: 15
---
## Defining taxonomies for a site
Taxonomies must be defined in the site configuration, before they can be
used throughout the site. You need to provide both the plural and
singular labels for each taxonomy.
Here is an example configuration in YAML that specifies two taxonomies.
Notice the format is **singular key** : *plural value*.
### config.yaml
---
Taxonomies:
tag: "tags"
category: "categories"
series: "series"
---
## Assigning taxonomy values to content
Once an taxonomy is defined at the site level, any piece of content
can be assigned to it regardless of content type or section.
Assigning content to an taxonomy is done in the front matter.
Simply create a variable with the *plural* name of the taxonomy
and assign all terms you want to apply to this content.
**taxonomy values are case insensitive**
### Front Matter Example (in JSON)
{
"title": "Hugo: A fast and flexible static site generator",
"tags": [
"Development",
"Go",
"fast",
"Blogging"
],
"categories" : [
"Development"
],
"series" : [
"Go Web Dev"
],
"slug": "hugo",
"project_url": "http://github.com/spf13/hugo"
}
+41
View File
@@ -0,0 +1,41 @@
---
aliases:
- /layout/404/
date: 2013-08-21
linktitle: "404"
menu:
main:
parent: layout
next: /taxonomies/overview
notoc: true
prev: /templates/sitemap
title: 404.html Templates
weight: 100
---
When using Hugo with [GitHub Pages](http://pages.github.com/) you can provide
your own 404 template by creating a 404.html file in the root.
404 pages are of the type "node" and have all the [node
variables](/layout/variables/) available to use in the templates.
In addition to the standard node variables, the homepage has access to
all site content accessible from .Data.Pages
▾ layouts/
404.html
## 404.html
This is a basic example of a 404.html template:
{{ template "chrome/header.html" . }}
{{ template "chrome/subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
</div>
</section>
{{ template "chrome/footer.html" }}
+161
View File
@@ -0,0 +1,161 @@
---
aliases:
- /layout/functions/
date: 2013-07-01
linktitle: Single Content
menu:
main:
parent: layout
next: /templates/list
prev: /templates/variables
title: Single Content Template
weight: 30
---
The primary view of content in hugo is the single view. Hugo for every
markdown file provided hugo will render it with a single template.
## Which Template will be rendered?
Hugo uses a set of rules to figure out which template to use when
rendering a specific page.
Hugo will use the following prioritized list. If a file isnt present
than the next one in the list will be used. This enables you to craft
specific layouts when you want to without creating more templates
then necessary. For most sites only the \_default file at the end of
the list will be needed.
Users can specify the `type` and `layout` in the [front-matter](/content/front-matter). `Section`
is determined based on the content files location. If `type` is provide
it will be used instead of `section`.
### Single
* /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/\_default/single.html
## Example Single Template File
Content pages are of the type "page" and have all the [page
variables](/layout/variables/) and [site
variables](/templates/variables/) available to use in the templates.
In the following examples we have created two different content types as well as
a default content type.
The default content template to be used in the event that a specific
template has not been provided for that type. The default type works the
same as the other types but the directory must be called "\_default".
▾ layouts/
▾ _default/
single.html
▾ post/
single.html
▾ project/
single.html
## post/single.html
This content template is used for [spf13.com](http://spf13.com).
It makes use of [partial templates](/layout/partials)
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
{{ $baseurl := .Site.BaseUrl }}
<section id="main">
<h1 id="title">{{ .Title }}</h1>
<div>
<article id="content">
{{ .Content }}
</article>
</div>
</section>
<aside id="meta">
<div>
<section>
<h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4>
<h5 id="wc"> {{ .FuzzyWordCount }} Words </h5>
</section>
<ul id="categories">
{{ range .Params.topics }}
<li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
<ul id="tags">
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
</div>
<div>
{{ if .Prev }}
<a class="previous" href="{{.Prev.Permalink}}"> {{.Prev.Title}}</a>
{{ end }}
{{ if .Next }}
<a class="next" href="{{.Next.Permalink}}"> {{.Next.Title}}</a>
{{ end }}
</div>
</aside>
{{ partial "disqus.html" . }}
{{ partial "footer.html" . }}
## project/single.html
This content template is used for [spf13.com](http://spf13.com).
It makes use of [partial templates](/layout/partials)
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
{{ $baseurl := .Site.BaseUrl }}
<section id="main">
<h1 id="title">{{ .Title }}</h1>
<div>
<article id="content">
{{ .Content }}
</article>
</div>
</section>
<aside id="meta">
<div>
<section>
<h4 id="date"> {{ .Date.Format "Mon Jan 2, 2006" }} </h4>
<h5 id="wc"> {{ .FuzzyWordCount }} Words </h5>
</section>
<ul id="categories">
{{ range .Params.topics }}
<li><a href="{{ $baseurl }}/topics/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
<ul id="tags">
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> </li>
{{ end }}
</ul>
</div>
</aside>
{{if isset .Params "project_url" }}
<div id="ribbon">
<a href="{{ index .Params "project_url" }}" rel="me">Fork me on GitHub</a>
</div>
{{ end }}
{{ partial "footer.html" }}
Notice how the project/single.html template uses an additional parameter unique
to this template. This doesn't need to be defined ahead of time. If the key is
present in the front matter than it can be used in the template. To
easily generate new content of this type with these keys ready use
[content archetypes](/content/archetypes).
+130
View File
@@ -0,0 +1,130 @@
---
aliases:
- /layout/functions/
date: 2013-07-01
linktitle: Functions
menu:
main:
parent: layout
next: /templates/variables
prev: /templates/go-templates
title: Hugo Template Functions
weight: 20
---
Hugo uses the excellent Go html/template library for its template engine.
It is an extremely lightweight engine that provides a very small amount of
logic. In our experience it is just the right amount of logic to be able
to create a good static website.
Go templates are lightweight but extensible. Hugo has added the following
functions to the basic template logic.
Go documentation for the built-in functions can be found [here](http://golang.org/pkg/text/template/)
## General
### isset
Return true if the parameter is set.
Takes either a slice, array or channel and an index or a map and a key as input.
eg. {{ if isset .Params "project_url" }} {{ index .Params "project_url" }}{{ end }}
### echoParam
If parameter is set, then echo it.
eg. {{echoParam .Params "project_url" }}
### first
Slices an array to only the first X elements.
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
eg.
{{ range first 10 .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
### where
Filters an array to only elements containing a matching value for a given field.
Works on [lists](/templates/list/), [taxonomies](/taxonomies/displaying/), [terms](/templates/terms/), [groups](/templates/list/)
eg.
{{ range where .Data.Pages "Section" "post" }}
{{ .Content}}
{{ end }}
*where and first can be stacked*
eg.
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ .Content}}
{{ end }}
## Math
### add
Adds two integers.
eg {{add 1 2}} -> 3
### sub
Subtracts two integers.
eg {{sub 3 2}} -> 1
### div
Divides two integers.
eg {{div 6 3}} -> 2
### mul
Multiplies two integers.
eg {{mul 2 3}} -> 6
### mod
Modulus of two integers.
eg {{mod 15 3}} -> 0
### modBool
Boolean of modulus of two integers.
true if modulus is 0.
eg {{modBool 15 3}} -> true
## Strings
### urlize
Takes a string and sanitizes it for usage in urls, converts spaces to "-".
eg. &lt;a href="/tags/{{ . | urlize }}"&gt;{{ . }}&lt;/a&gt;
### safeHtml
Declares the provided string as "safe" so go templates will not filter it.
eg. {{ .Params.CopyrightHTML | safeHtml }}
### lower
Convert all characters in string to lowercase.
eg {{lower "BatMan"}} -> "batman"
### upper
Convert all characters in string to uppercase.
eg {{upper "BatMan"}} -> "BATMAN"
### title
Convert all characters in string to titlecase.
eg {{title "BatMan"}} -> "Batman"
### highlight
Take a string of code and a language, uses pygments to return the syntax
highlighted code in html. Used in the [highlight shortcode](/extras/highlighting).
+348
View File
@@ -0,0 +1,348 @@
---
aliases:
- /layout/go-templates/
- /layouts/go-templates/
date: 2013-07-01
menu:
main:
parent: layout
next: /templates/functions
prev: /templates/overview
title: Go Template Primer
weight: 15
---
Hugo uses the excellent [Go][] [html/template][gohtmltemplate] library for
its template engine. It is an extremely lightweight engine that provides a very
small amount of logic. In our experience it is just the right amount of
logic to be able to create a good static website. If you have used other
template systems from different languages or frameworks, you will find a lot of
similarities in Go templates.
This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate]
provide more details.
## Introduction to Go Templates
Go templates provide an extremely simple template language. It adheres to the
belief that only the most basic of logic belongs in the template or view layer.
One consequence of this simplicity is that Go templates parse very quickly.
A unique characteristic of Go templates is they are content aware. Variables and
content will be sanitized depending on the context of where they are used. More
details can be found in the [Go docs][gohtmltemplate].
## Basic Syntax
Go lang templates are html files with the addition of variables and
functions.
**Go variables and functions are accessible within {{ }}**
Accessing a predefined variable "foo":
{{ foo }}
**Parameters are separated using spaces**
Calling the add function with input of 1, 2:
{{ add 1 2 }}
**Methods and fields are accessed via dot notation**
Accessing the Page Parameter "bar"
{{ .Params.bar }}
**Parentheses can be used to group items together**
{{ if or (isset .Params "alt") (isset .Params "caption") }} Caption {{ end }}
## Variables
Each Go template has a struct (object) made available to it. In Hugo each
template is passed either a page or a node struct depending on which type of
page you are rendering. More details are available on the
[variables](/layout/variables) page.
A variable is accessed by referencing the variable name.
<title>{{ .Title }}</title>
Variables can also be defined and referenced.
{{ $address := "123 Main St."}}
{{ $address }}
## Functions
Go template ship with a few functions which provide basic functionality. The go
template system also provides a mechanism for applications to extend the
available functions with their own. [Hugo template
functions](/layout/functions) provide some additional functionality we believe
are useful for building websites. Functions are called by using their name
followed by the required parameters separated by spaces. Template
functions cannot be added without recompiling hugo.
**Example:**
{{ add 1 2 }}
## Includes
When including another template you will pass to it the data it will be
able to access. To pass along the current context please remember to
include a trailing dot. The templates location will always be starting at
the /layout/ directory within Hugo.
**Example:**
{{ template "chrome/header.html" . }}
## Logic
Go templates provide the most basic iteration and conditional logic.
### Iteration
Just like in Go, the Go templates make heavy use of range to iterate over
a map, array or slice. The following are different examples of how to use
range.
**Example 1: Using Context**
{{ range array }}
{{ . }}
{{ end }}
**Example 2: Declaring value variable name**
{{range $element := array}}
{{ $element }}
{{ end }}
**Example 2: Declaring key and value variable name**
{{range $index, $element := array}}
{{ $index }}
{{ $element }}
{{ end }}
### Conditionals
If, else, with, or, & and provide the framework for handling conditional
logic in Go Templates. Like range, each statement is closed with `end`.
Go Templates treat the following values as false:
* false
* 0
* any array, slice, map, or string of length zero
**Example 1: If**
{{ if isset .Params "title" }}<h4>{{ index .Params "title" }}</h4>{{ end }}
**Example 2: If -> Else**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{else}}
{{ index .Params "caption" }}
{{ end }}
**Example 3: And & Or**
{{ if and (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
**Example 4: With**
An alternative way of writing "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent.
The first example above could be simplified as:
{{ with .Params.title }}<h4>{{ . }}</h4>{{ end }}
**Example 5: If -> Else If**
{{ if isset .Params "alt" }}
{{ index .Params "alt" }}
{{ else if isset .Params "caption" }}
{{ index .Params "caption" }}
{{ end }}
## Pipes
One of the most powerful components of Go templates is the ability to
stack actions one after another. This is done by using pipes. Borrowed
from unix pipes, the concept is simple, each pipeline's output becomes the
input of the following pipe.
Because of the very simple syntax of Go templates, the pipe is essential
to being able to chain together function calls. One limitation of the
pipes is that they only can work with a single value and that value
becomes the last parameter of the next pipeline.
A few simple examples should help convey how to use the pipe.
**Example 1 :**
{{ if eq 1 1 }} Same {{ end }}
is the same as
{{ eq 1 1 | if }} Same {{ end }}
It does look odd to place the if at the end, but it does provide a good
illustration of how to use the pipes.
**Example 2 :**
{{ index .Params "disqus_url" | html }}
Access the page parameter called "disqus_url" and escape the HTML.
**Example 3 :**
{{ if or (or (isset .Params "title") (isset .Params "caption")) (isset .Params "attr")}}
Stuff Here
{{ end }}
Could be rewritten as
{{ isset .Params "caption" | or isset .Params "title" | or isset .Params "attr" | if }}
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 (a.k.a. the dot)
The most easily overlooked concept to understand about Go templates is that `{{ . }}`
always refers to the current context. In the top level of your template this
will be the data set made available to it. Inside of a iteration it will have
the value of the current item. When inside of a loop the context has changed.
`.` will no longer refer to the data available to the entire page. If you need
to
access this from within the loop, you will likely want to set it to a variable
instead of depending on the context.
**Example:**
{{ $title := .Site.Title }}
{{ range .Params.tags }}
<li> <a href="{{ $baseurl }}/tags/{{ . | urlize }}">{{ . }}</a> - {{ $title }} </li>
{{ end }}
Notice how once we have entered the loop the value of `{{ . }}` has changed. We
have defined a variable outside of the loop so we have access to it from within
the loop.
# Hugo Parameters
Hugo provides the option of passing values to the template language
through the site configuration (for sitewide values), or through the meta
data of each specific piece of content. You can define any values of any
type (supported by your front matter/config format) and use them however
you want to inside of your templates.
## Using Content (page) Parameters
In each piece of content you can provide variables to be used by the
templates. This happens in the [front matter](/content/front-matter).
An example of this is used in this documentation site. Most of the pages
benefit from having the table of contents provided. Sometimes the TOC just
doesn't make a lot of sense. We've defined a variable in our front matter
of some pages to turn off the TOC from being displayed.
Here is the example front matter:
```
---
title: "Permalinks"
date: "2013-11-18"
aliases:
- "/doc/permalinks/"
groups: ["extras"]
groups_weight: 30
notoc: true
---
```
Here is the corresponding code inside of the template:
{{ if not .Params.notoc }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>
{{ end }}
## Using Site (config) Parameters
In your top-level configuration file (eg, `config.yaml`) you can define site
parameters, which are values which will be available to you in chrome.
For instance, you might declare:
```yaml
params:
CopyrightHTML: "Copyright &#xA9; 2013 John Doe. All Rights Reserved."
TwitterUser: "spf13"
SidebarRecentLimit: 5
```
Within a footer layout, you might then declare a `<footer>` which is only
provided if the `CopyrightHTML` parameter is provided, and if it is given,
you would declare it to be HTML-safe, so that the HTML entity is not escaped
again. This would let you easily update just your top-level config file each
January 1st, instead of hunting through your templates.
```
{{if .Site.Params.CopyrightHTML}}<footer>
<div class="text-center">{{.Site.Params.CopyrightHTML | safeHtml}}</div>
</footer>{{end}}
```
An alternative way of writing the "if" and then referencing the same value
is to use "with" instead. With rebinds the context `.` within its scope,
and skips the block if the variable is absent:
```
{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
alt="Twitter"></a>
</span>{{end}}
```
Finally, if you want to pull "magic constants" out of your layouts, you can do
so, such as in this example:
```
<nav class="recent">
<h1>Recent Posts</h1>
<ul>{{range first .Site.Params.SidebarRecentLimit .Site.Recent}}
<li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
{{end}}</ul>
</nav>
```
[go]: http://golang.org/
[gohtmltemplate]: http://golang.org/pkg/html/template/
+78
View File
@@ -0,0 +1,78 @@
---
aliases:
- /layout/homepage/
date: 2013-07-01
menu:
main:
parent: layout
next: /templates/terms
notoc: true
prev: /templates/list
title: Homepage
weight: 50
---
The home page of a website is often formatted differently than the other
pages. In Hugo you can define your own homepage template.
Homepage is of the type "node" and have all the [node
variables](/templates/variables/) and [site
variables](/templates/variables/) available to use in the templates.
*This is the only required template for building a site and useful when
bootstrapping a new site and template. It is also the only required
template when using a single page site.*
In addition to the standard node variables, the homepage has access to
all site content accessible from .Data.Pages . Details on how to use the
list of pages can be found in the [Lists Template](/templates/list/)
## Which Template will be rendered?
Hugo uses a set of rules to figure out which template to use when
rendering a specific page.
Hugo will use the following prioritized list. If a file isnt present
than the next one in the list will be used. This enables you to craft
specific layouts when you want to without creating more templates
then necessary. For most sites only the \_default file at the end of
the list will be needed.
* /layouts/index.html
* /layouts/\_default/list.html
* /layouts/\_default/single.html
* /themes/`THEME`/layouts/index.html
* /themes/`THEME`/layouts/\_default/list.html
* /themes/`THEME`/layouts/\_default/single.html
## example index.html
This content template is used for [spf13.com](http://spf13.com).
It makes use of [partial templates](/templates/partials) and uses a similar approach as a [List](/templates/list/).
<!DOCTYPE html>
<html class="no-js" lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<head>
<meta charset="utf-8">
{{ partial "meta.html" . }}
<base href="{{ .Site.BaseUrl }}">
<title>{{ .Site.Title }}</title>
<link rel="canonical" href="{{ .Permalink }}">
<link href="{{ .RSSlink }}" rel="alternate" type="application/rss+xml" title="{{ .Site.Title }}" />
{{ partial "head_includes.html" . }}
</head>
<body lang="en">
{{ partial "subheader.html" . }}
<section id="main">
<div>
{{ range first 10 .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ partial "footer.html" }}
+338
View File
@@ -0,0 +1,338 @@
---
aliases:
- /layout/indexes/
date: 2013-07-01
linktitle: List of Content
menu:
main:
parent: layout
next: /templates/homepage
prev: /templates/content
title: Content List Template
weight: 40
---
A list template is any template that will be used to render multiple pieces of
content in a single html page (with the exception of the [homepage](/layout/homepage) which has a
dedicated template).
We are using the term list in its truest sense, a sequential arrangement
of material, especially in alphabetical or numerical order. Hugo uses
list templates to render anyplace where content is being listed such as
taxonomies and sections.
## Which Template will be rendered?
Hugo uses a set of rules to figure out which template to use when
rendering a specific page.
Hugo will use the following prioritized list. If a file isnt present
than the next one in the list will be used. This enables you to craft
specific layouts when you want to without creating more templates
then necessary. For most sites only the \_default file at the end of
the list will be needed.
### Section Lists
A Section will be rendered at /`SECTION`/
* /layouts/section/`SECTION`.html
* /layouts/\_default/section.html
* /layouts/\_default/list.html
* /themes/`THEME`/layouts/section/`SECTION`.html
* /themes/`THEME`/\_default/section.html
* /themes/`THEME`/layouts/\_default/list.html
### Taxonomy Lists
A Taxonomy will be rendered at /`PLURAL`/`TERM`/
* /layouts/taxonomy/`SINGULAR`.html
* /layouts/\_default/taxonomy.html
* /layouts/\_default/list.html
* /themes/`THEME`/layouts/taxonomy/`SINGULAR`.html
* /themes/`THEME`/\_default/taxonomy.html
* /themes/`THEME`/layouts/\_default/list.html
### Section RSS
A Sections RSS will be rendered at /`SECTION`/index.xml
*Hugo ships with its own ATOM 2.0 RSS template. In most cases this will
be sufficient and an RSS template will not need to be provided by the
user.*
Hugo provides the ability for you to define any RSS type you wish, and
can have different RSS files for each section and taxonomy.
* /layouts/section/`SECTION`.rss.xml
* /layouts/\_default/rss.xml
* /themes/`THEME`/layouts/section/`SECTION`.rss.xml
* /themes/`THEME`/layouts/\_default/rss.xml
### Taxonomy RSS
A Taxonomys RSS will be rendered at /`PLURAL`/`TERM`/index.xml
*Hugo ships with its own ATOM 2.0 RSS template. In most cases this will
be sufficient and an RSS template will not need to be provided by the
user.*
Hugo provides the ability for you to define any RSS type you wish, and
can have different RSS files for each section and taxonomy.
* /layouts/taxonomy/`SINGULAR`.rss.xml
* /layouts/\_default/rss.xml
* /themes/`THEME`/layouts/taxonomy/`SINGULAR`.rss.xml
* /themes/`THEME`/layouts/\_default/rss.xml
## Variables
List pages are of the type "node" and have all the [node
variables](/templates/variables/) and [site
variables](/templates/variables/) available to use in the templates.
Taxonomy pages will additionally have:
**.Data.`singular`** The taxonomy itself.<br>
## Example List Template Pages
### Example section template (post.html)
This content template is used for [spf13.com](http://spf13.com).
It makes use of [partial templates](/templates/partials). All examples use a
[view](/templates/views/) called either "li" or "summary" which this example site
defined.
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
<ul id="list">
{{ range .Data.Pages }}
{{ .Render "li"}}
{{ end }}
</ul>
</div>
</section>
{{ partial "footer.html" }}
### Example taxonomy template (tag.html)
This content template is used for [spf13.com](http://spf13.com).
It makes use of [partial templates](/templates/partials). All examples use a
[view](/templates/views/) called either "li" or "summary" which this example site
defined.
{{ partial "header.html" . }}
{{ partial "subheader.html" . }}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{ partial "footer.html" }}
## Ordering Content
In the case of Hugo each list will render the content based on metadata provided in the [front
matter](/content/front-matter). See [ordering content](/content/ordering) for more information.
Here are a variety of different ways you can order the content items in
your list templates:
### Order by Weight -> Date (default)
{{ range .Data.Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Order by Weight -> Date
{{ range .Data.Pages.ByWeight }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Order by Date
{{ range .Data.Pages.ByDate }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Order by Length
{{ range .Data.Pages.ByLength }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Order by Title
{{ range .Data.Pages.ByTitle }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Order by LinkTitle
{{ range .Data.Pages.ByLinkTitle }}
<li>
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
### Reverse Order
Can be applied to any of the above. Using Date for an example.
{{ range .Data.Pages.ByDate.Reverse }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
## Grouping Content
Hugo provides some grouping functions for list pages. You can use them to
group pages by Section, Date etc.
Here are a variety of different ways you can group the content items in
your list templates:
### Grouping by Page field
{{ range .Data.Pages.GroupBy "Section" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
</ul>
{{ end }}
### Grouping by Page date
{{ range .Data.Pages.GroupByDate "2006-01" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
</ul>
{{ end }}
### Reversing Key Order
The ordering of the groups is performed by keys in alpha-numeric order (A-Z,
1-100) and in reverse chronological order (newest first) for dates.
While these are logical defaults, they are not always the desired order. There
are two different syntaxes to change the order, they both work the same way, so
its really just a matter of preference.
#### Reverse method
{{ range (.Data.Pages.GroupBy "Section").Reverse }}
...
{{ range (.Data.Pages.GroupByDate "2006-01").Reverse }}
...
#### Providing the (alternate) direction
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
...
{{ range .Data.Pages.GroupBy "Section" "desc" }}
...
### Ordering Pages within Group
Because Grouping returns a key and a slice of pages all of the ordering methods listed above are available.
In this example Ive ordered the groups in chronological order and the content
within each group in alphabetical order by title.
{{ range .Data.Pages.GroupByDate "2006-01" "asc" }}
<h3>{{ .Key }}</h3>
<ul>
{{ range .Pages.ByTitle }}
<li>
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
</li>
{{ end }}
</ul>
{{ end }}
## Filtering & Limiting Content
Sometimes you only want to list a subset of the available content. A common
request is to only display “Posts” on the homepage. Using the `where` function
you can do just that.
### First
`first` works like the limit keyword in SQL. It reduces the array to only the
first X elements. It takes the array and number of elements as input.
{{ range first 10 .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
### Where
`where` works in a similar manner to the where keyword in SQL. It selects all
elements of the slice that match the provided field and value. It takes three
arguments 'array or slice of maps or structs', 'key or field name' and 'match
value'
{{ range where .Data.Pages "Section" "post" }}
{{ .Content}}
{{ end }}
### First & Where Together
Using both together can be very powerful.
{{ range first 5 (where .Data.Pages "Section" "post") }}
{{ .Content}}
{{ end }}
If `where` or `first` receives invalid input or a field name that doesnt exist they will provide an error and stop site generation.
These are both template functions and work on not only
[lists](/templates/list/), but [taxonomies](/taxonomies/displaying/),
[terms](/templates/terms/) and [groups](/templates/list/).
+72
View File
@@ -0,0 +1,72 @@
---
aliases:
- /doc/templates/
- /layout/templates/
- /layout/overview/
date: 2013-07-01
linktitle: Overview
menu:
main:
parent: layout
next: /templates/go-templates
prev: /themes/creation
title: Hugo Templates
weight: 10
---
Hugo uses the excellent Go html/template library for its template engine.
It is an extremely lightweight engine that provides a very small amount of
logic. In our experience it is just the right amount of logic to be able
to create a good static website.
While Hugo has a number of different template roles, most complete
websites can be built using just a small number of template files.
Please dont be afraid of the variety of different template roles. They
enable Hugo to build very complicated sites. Most sites will only
need to create a [/layouts/\_default/single.html](/templates/content) & [/layouts/\_default/list.html](/templates/list)
If you are new to Go's templates, the [Go Template Primer](/layout/go-templates)
is a great place to start.
If you are familiar with Gos templates, Hugo provides some [additional
template functions](/templates/functions) and [variables](/templates/variables) you will want to be familiar
with.
## Primary Template roles
There are 3 primary kinds of templates that Hugo works with.
### [Single](/templates/content)
Render a single piece of content
### [List](/templates/list)
Page that list multiple pieces of content
### [Homepage](/templates/homepage/)
The homepage of your site
## Supporting Template Roles (optional)
Hugo also has additional kinds of templates all of which are optional
### [Partial Templates](/templates/partials)
Common page parts to be included in the above mentioned templates
### [Content Views](/templates/views)
Different ways of rendering a (single) content type
### [Taxonomy Terms](/templates/terms)
A list of the terms used for a specific taxonomy, e.g. a Tag cloud
## Other Templates (generally unnecessary)
### [RSS](/templates/rss/)
Used to render all rss documents
### [Sitemap](/templates/sitemap/)
Used to render the XML sitemap
### [404](/templates/404)
This template will create a 404.html page used when hosting on GitHub Pages

Some files were not shown because too many files have changed in this diff Show More