Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
tummychow committed Mar 14, 2014
0 parents commit 3f0005b
Show file tree
Hide file tree
Showing 22 changed files with 1,338 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.json text
*.yaml text
*.toml text

*.html text
*.md text
*.xml text
*.css text
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
jekyll/**
public/**
hugout/**
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing

So you want to help me with Lanyon-Hugo? **AWESOME**!

I'm not a designer, nor do I know CSS or HTML. Most of those things are coming straight out of the original Lanyon. However, the parts that make it work with Hugo, those are mine. And if you're interested, what's mine is yours. I'll explain what has changed from the original Lanyon, if you were familiar with that theme already. And I'll explain the structure of this Hugo theme, assuming you already understand some of how Hugo works.

Hugo's docs are a bit lacking in the "big picture" of how things fit together (I might submit a PR when I'm more familiar with the tool), but they're quite complete. I recommend you read them first.

## Layouts
Lanyon-Hugo uses two content types, `fixed` and `post`. These are analogous to Lanyon's `page` and `post` layouts, respectively. Right now, I only have single views for these content types. I will probably add a list view for `post` in the future.

The two types are quite similar. In fact, the only difference is that `post` shows a date, where as `fixed` does not. [This](http://golang.org/pkg/time/#Time.Format) documentation explains how to change the date formatting.

Both content types call out to a set of general HTML files which provide the universal bits and pieces. These are stored in `layouts/chrome`, which is a Hugo convention, and they are analogous to Lanyon's `_includes`.

In Jekyll, you can nest layouts. Lanyon's `page` and `post` layouts are both based on a `default` layout. The `default` layout is the one that provides things like the header and the sidebar. But Hugo doesn't have this functionality, so I took the `default` layout, and I split it into two files: `default_head.html` and `default_foot.html`. These two are meant to be included at the top and bottom, respectively, of any other content views. You can see this in `fixed/single.html` and `post/single.html`.

## Sidebar
The most interesting layout is probably `layouts/chrome/sidebar.html`. This is mostly based on Lanyon's `_includes/sidebar.html`, but ported to Go templates instead of Liquid. We identify the homepage via `.Url`. Any pages whose front matter sets the `sidebar` flag are also added to the sidebar. We match the active page (if any) using its `.Permalink`. The sidebar also retains the GitHub integration from the original Lanyon, where it lists a repository of your choice.

## Homepage
Hugo implements homepages as a special layout, which does not correspond to any content type. This gets generated into a page called a node. You can see this in `layouts/index.html`. If you want to change the number of posts listed on the homepage, just change the `pagination` variable. One inconvenience of Hugo's system is that you can't include front matter for nodes (as far as I know).

The index implements a full view of each item whose content type is `post`. This is quite repetitive and overlaps heavily with `post/single.html`. I plan to add a `post/summary.html` in the future, which does not include the default header and footer, and which sets the post title to a link. Then, I can replace this with `{{ .Render "summary" }}` to reduce code repetition.

You may notice that the pagination buttons from the original Lanyon are conspicuously missing. Jekyll has a pagination feature which generates extra HTML in the output site, so that you can go through pages of past posts easily. This isn't available in Hugo yet. Hugo provides indexes, which can list stuff, but breaking those lists into paginated pieces is another matter. I am probably going to wait until Hugo provides support for this feature. Then I'll add the pagination buttons back.

## Statics
Jekyll will take every file in its source directory and mirror it in the destination, unless the file's name begins with an underscore. Hugo is not quite so inclusive. The contents of the `static` directory are mirrored into the root of the destination exactly as they are. This is where the Lanyon/Poole CSS files are placed. I have not changed those files at all (literally nothing).

If your GitHub Page has a custom name, the `CNAME` file should go in this directory.

## Custom 404
The custom 404 is implemented as a fixed page, but where the `sidebar` flag is not set. It's aliased to `404.html`. If you use the `url` front matter key, it will be prettified, so if you set `"url": "/404.html"`, then you end up with `404/index.html` in your generated site instead of `404.html`. Aliases are explicit, so I guess it gets around that problem. It feels like a hack to me, but it seems to work.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Lanyon for Hugo

[Lanyon](http://github.com/poole/lanyon) is a great theme for [Jekyll](http://jekyllrb.com). This is a port of that theme, but to another static site generator, [Hugo](http://github.com/spf13/hugo). I'm aiming to get the same look and interactions as the original Lanyon.

Hugo and Jekyll are similar in that, out of the box, you can't make a presentable website out of them. You need some kind of theme first, or otherwise your site will be *really* bare-bones. If you're a designer, you might be comfortable doing that yourself. If you aren't, Jekyll has a thriving ecosystem of themes waiting for you. Hugo, being younger than Jekyll, does not. Lanyon-Hugo attempts to remedy that problem.

Lanyon-Hugo is a theme designed for blogging. While Hugo is flexible enough to turn almost any static content into a website, this theme is focused on blog-like use cases. Lanyon-Hugo retains the CSS, and therefore the look and feel, of the parent theme, Lanyon. This includes a sidebar that is hidden by default, and can be toggled with a button (implemented entirely in CSS). The sidebar gives some convenient navigation links, but when it is hidden, Lanyon-Hugo, just like Lanyon, is discreet and puts your content front and center.

## Usage

To begin authoring content, all you have to do is clone this repository and start writing Markdown files in `content/post`. Front matter for Hugo can be written in JSON, YAML or TOML. I am using JSON out of preference, but it's your content - use whatever language you want. Two example posts are already provided (lifted from the parent Lanyon, with links fixed for Hugo) as an example of the front matter you need.

Note for Jekyll users: Jekyll parses the date out of your post's title, but Hugo does not. You must specify a date in the front matter. I specify the permalinks to look like Jekyll's in `config.json`, so if you set the date correctly, the permalinks will also look correct.

Hugo's universal config file is `config.json` (or YAML, or TOML). You can change the base URL of your site, the title, and the tagline from this file. The link to your GitHub repository (for whatever the site represents, say a dev blog, or a personal GitHub Page) can also be changed here. If you are familiar with Hugo, you already know that you can add more parameters to the `params` object to introduce more variables.

### Fixed Pages

The original Lanyon had a layout for "pages", fixed content that didn't have a date. Lanyon-Hugo retains this concept, and refers to these pages as "fixed" (that's the content type, if you're familiar with Hugo concepts). Fixed pages will not display a date, only a title, and they will not be listed on the homepage of your site. Pages such as About (an example `about.md` has been lifted from the parent Lanyon) should generally be fixed.

You can alter the content of the custom 404 via `fixed/404.md`. This is useful if you want a custom 404 for your GitHub Page.

### Sidebar Links

To indicate that a given piece of content should be linked in the sidebar, add a key `sidebar` to the front matter, and set it to `true`. See `about.md` for an example of this. Sidebar links currently appear in an arbitrary order; this will be improved in the future. You can pin content to the sidebar regardless of whether it is a post, or if it is fixed.

Note for Jekyll users: In the original Lanyon, any content that had the `page` layout would be added to the sidebar. However, in Lanyon-Hugo, content with the `fixed` type will not be added to the sidebar automatically. You must specify the `sidebar` flag in the front matter.

### Look and Feel

The CSS from the original Lanyon is unchanged, and you can find it in `static/css`. Any of the modifications suggested for Lanyon can also be applied to Lanyon-Hugo, by changing the CSS here.

## To Do

While Lanyon-Hugo is aiming for functional compatibility with Lanyon (ie all the old functionality is available and looks similar), there are still some things I'm missing:
- pagination. Lanyon-Hugo does not have next/previous buttons. Jekyll's pagination feature is quite good, but Hugo's pagination is still on the roadmap for now. I may implement a hackish solution in the meantime, but ideally I'd rather wait until Hugo has a solid solution for this problem.
- syntax highlighting in posts. I don't understand a lot about Hugo's syntax highlighting feature, not because it's undocumented but because I haven't read the docs yet. It's in the pipeline.

## Contributing

If you're interested in hacking on this theme, please check out [CONTRIBUTING](CONTRIBUTING.md).

## License
None for now. Not a big priority for me. But it'll probably be MIT.
24 changes: 24 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"contentdir": "content",
"layoutdir": "layouts",
"publishdir": "public",

"builddrafts": false,

"baseurl": "http://tummychow.github.io/lanyon-hugo/",
"canonifyurls": true,
"permalinks": {
"post": "/:year/:month/:day/:title/",
"fixed": "/:title/"
},

"params": {
"Title": "Lanyon",
"Tagline": "A Jekyll theme",
"Author": "Mark Otto",
"Github": {
"Url": "http://github.com/tummychow/lanyon-hugo",
"Head": "master"
}
}
}
6 changes: 6 additions & 0 deletions content/fixed/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"aliases": ["/404.html"],
"title": "404"
}

Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. [Head back home](/) to try finding it again.
30 changes: 30 additions & 0 deletions content/fixed/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"title": "About",
"sidebar": true
}

<p class="message">
Hey there! This page is included as an example. Feel free to customize it for your own use upon downloading. Carry on!
</p>

In the novel, *The Strange Case of Dr. Jeykll and Mr. Hyde*, Mr. Poole is Dr. Jekyll's virtuous and loyal butler. Similarly, Poole is an upstanding and effective butler that helps you build Jekyll themes. It's made by [@mdo](https://twitter.com/mdo).

There are currently two themes built on Poole:

* [Hyde](http://hyde.getpoole.com)
* [Lanyon](http://lanyon.getpoole.com)

Learn more and contribute on [GitHub](https://github.com/poole).

## Setup

Some fun facts about the setup of this project include:

* Built for [Jekyll](http://jekyllrb.com)
* Developed on GitHub and hosted for free on [GitHub Pages](https://pages.github.com)
* Coded with [Sublime Text 2](http://sublimetext.com), an amazing code editor
* Designed and developed while listening to music like [Blood Bros Trilogy](https://soundcloud.com/maddecent/sets/blood-bros-series)

Have questions or suggestions? Feel free to [open an issue on GitHub](https://github.com/poole/issues/new) or [ask me on Twitter](https://twitter.com/mdo).

Thanks for reading!
12 changes: 12 additions & 0 deletions content/post/2013-12-31-whats-jekyll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"title": "What's Jekyll?",
"date": "2013-12-31"
}

[Jekyll](http://jekyllrb.com) is a static site generator, an open-source tool for creating simple yet powerful websites of all shapes and sizes. From [the project's readme](https://github.com/mojombo/jekyll/blob/master/README.markdown):

> Jekyll is a simple, blog aware, static site generator. It takes a template directory [...] and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.
It's an immensely useful tool and one we encourage you to use here with Hyde.

Find out more by [visiting the project on GitHub](https://github.com/mojombo/jekyll).
38 changes: 38 additions & 0 deletions content/post/2014-01-02-introducing-lanyon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"title": "Introducing Lanyon",
"date": "2014-01-02"
}

Lanyon is an unassuming [Jekyll](http://jekyllrb.com) theme that places content first by tucking away navigation in a hidden drawer. It's based on [Poole](http://getpoole.com), the Jekyll butler.

### Built on Poole

Poole is the Jekyll Butler, serving as an upstanding and effective foundation for Jekyll themes by [@mdo](https://twitter.com/mdo). Poole, and every theme built on it (like Lanyon here) includes the following:

* Complete Jekyll setup included (layouts, config, [404](/404), [RSS feed](/index.xml), posts, and [example page](/about))
* Mobile friendly design and development
* Easily scalable text and component sizing with `rem` units in the CSS
* Support for a wide gamut of HTML elements
* Related posts (time-based, because Jekyll) below each post
* Syntax highlighting, courtesy Pygments (the Python-based code snippet highlighter)

### Lanyon features

In addition to the features of Poole, Lanyon adds the following:

* Toggleable sliding sidebar (built with only CSS) via **** link in top corner
* Sidebar includes support for textual modules and a dynamically generated navigation with active link support
* Two orientations for content and sidebar, default (left sidebar) and [reverse](https://github.com/poole/lanyon#reverse-layout) (right sidebar), available via `<body>` classes
* [Eight optional color schemes](https://github.com/poole/lanyon#themes), available via `<body>` classes

[Head to the readme](https://github.com/poole/lanyon#readme) to learn more.

### Browser support

Lanyon is by preference a forward-thinking project. In addition to the latest versions of Chrome, Safari (mobile and desktop), and Firefox, it is only compatible with Internet Explorer 9 and above.

### Download

Lanyon is developed on and hosted with GitHub. Head to the <a href="https://github.com/poole/lanyon">GitHub repository</a> for downloads, bug reports, and features requests.

Thanks!
7 changes: 7 additions & 0 deletions layouts/chrome/default_foot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
</div>
</div>

<label for="sidebar-checkbox" class="sidebar-toggle"></label>

</body>
</html>
22 changes: 22 additions & 0 deletions layouts/chrome/default_head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">

{{ template "chrome/head.html" . }}

<body>

{{ template "chrome/sidebar.html" . }}

<!-- Wrap is the content to shift when toggling the sidebar. We wrap the
content to avoid any CSS collisions with our real content. -->
<div class="wrap">
<div class="masthead">
<div class="container">
<h3 class="masthead-title">
<a href="/" title="Home">{{ .Site.Params.Title }}</a>
<small>{{ .Site.Params.Tagline }}</small>
</h3>
</div>
</div>

<div class="container content">
28 changes: 28 additions & 0 deletions layouts/chrome/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<head>
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<!-- Enable responsiveness on mobile devices-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

<title>
{{ if eq .Url "/" }}
{{ .Site.Params.Title }} &middot; {{ .Site.Params.Tagline }}
{{ else }}
{{ .Title }} &middot; {{ .Site.Params.Title }}
{{ end }}
</title>

<!-- CSS -->
<link rel="stylesheet" href="/css/poole.css">
<link rel="stylesheet" href="/css/syntax.css">
<link rel="stylesheet" href="/css/lanyon.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400">

<!-- Icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/assets/apple-touch-icon-144-precomposed.png">
<link rel="shortcut icon" href="/assets/favicon.ico">

<!-- RSS -->
<link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">
</head>
29 changes: 29 additions & 0 deletions layouts/chrome/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular
styles, `#sidebar-checkbox` for behavior. -->
<input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">

<!-- Toggleable sidebar -->
<div class="sidebar" id="sidebar">
<div class="sidebar-item">
<p>A reserved <a href="http://jekyllrb.com" target="_blank">Jekyll</a> theme that places the utmost gravity on content with a hidden drawer. Made by <a href="https://twitter.com/mdo" target="_blank">@mdo</a>.</p>
</div>

<nav class="sidebar-nav">
<a class="sidebar-nav-item {{ if eq .Url "/" }} active {{ end }}" href="/">Home</a>

{{ $thisperma := .Permalink }}
{{ range .Site.Recent }}
{{ if isset .Params "sidebar" }}
<a class="sidebar-nav-item {{ if eq .Permalink $thisperma }} active {{ end }}" href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
{{ end }}

<a class="sidebar-nav-item" href="{{ .Site.Params.Github.Url }}/archive/{{ .Site.Params.Github.Head }}.zip">Download</a>
<a class="sidebar-nav-item" href="{{ .Site.Params.Github.Url }}">GitHub project</a>
<span class="sidebar-nav-item">Currently on {{ .Site.Params.Github.Head }}</span>
</nav>

<div class="sidebar-item">
<p>&copy; {{ .Site.LastChange.Year }}. All rights reserved.</p>
</div>
</div>
8 changes: 8 additions & 0 deletions layouts/fixed/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ template "chrome/default_head.html" . }}

<div class="page">
<h1 class="page-title">{{ .Title }}</h1>
{{ .Content }}
</div>

{{ template "chrome/default_foot.html" . }}
17 changes: 17 additions & 0 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ template "chrome/default_head.html" . }}

{{ $pagination := 5 }}

<div class="posts">
{{ range first $pagination .Data.Pages }}
{{ if eq .Type "post"}}
<div class="post">
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
<span class="post-date">{{ .Date.Format "Jan 2 2006" }}</span>
{{ .Content }}
</div>
{{ end }}
{{ end }}
</div>

{{ template "chrome/default_foot.html" . }}
9 changes: 9 additions & 0 deletions layouts/post/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{ template "chrome/default_head.html" . }}

<div class="post">
<h1 class="post-title">{{ .Title }}</h1>
<span class="post-date">{{ .Date.Format "Jan 2 2006" }}</span>
{{ .Content }}
</div>

{{ template "chrome/default_foot.html" . }}
24 changes: 24 additions & 0 deletions layouts/rss.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ .Site.Title }} </title>
<link>{{ .Permalink }}</link>
<language>en-us</language>
<author>{{ .Site.Params.Author }}</author>
<rights>(C) {{ .Site.LastChange.Year }}</rights>
<updated>{{ .Date }}</updated>

{{ range .Data.Pages }}
{{ if eq .Type "post"}}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</pubDate>
<author>{{ .Site.Params.Author }}</author>
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | html }}</description>
</item>
{{ end }}
{{ end }}

</channel>
</rss>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/assets/favicon.ico
Binary file not shown.
Loading

0 comments on commit 3f0005b

Please sign in to comment.