Ben Spoon
Front-end Developer @AWeber
Creating Static HTML sites with Assemble.io
$ npm install assemble --save-dev
npm install
add it to your Gruntfile
grunt.loadNpmTasks('assemble' );
setup the task
assemble: {
options: {
assets: "path/to/assets",
data: "path/to/config.json"
},
project: {
options: {
layout: "path/to/default-layout.hbs",
partials: "path/to/partials/**/*.hbs"
},
files: {
'dest': ["path/to/pages/**/*.hbs" ]
}
}
}
grunt.loadNpmTasks('assemble' );
grunt.registerTask('default', ['assemble' ]);
watch!
watch: {
files: ['templates/**/*', 'assets/css/**/*'],
tasks: ['build']
}
get sassy
sass: {
build: {
files: {
'./build/assets/css/main.css': './assets/css/main.scss'
}
}
}
copy all the things
copy: {
build: {
files: [
{expand: true, src: 'assets/css/*.css', dest: 'build'},
{expand: true, src: 'assets/js/*.js', dest: 'build'},
{expand: true, src: 'assets/img/**/*', dest: 'build'}
]
}
}
HANG
Assets
Templates
js
css
img
layouts
partials
<!DOCTYPE html>
<html lang="en">
<head>
{{> head }}
</head>
<body>
{{> header}}
{{> nav}}
<section class="main">
{{> body }}
</section>
{{> footer }}
{{> scripts}}
</body>
</html>
<!-- page title -->
<title>{{ page.title }}</title>
<!-- Meta junk -->
<meta charset="UTF-8">
<meta name="description" content="Small Buisness Website">
<meta name="keywords" content=" ">
<meta name="author" content="Ben Spoon">
<!-- CSS Files -->
<link href="assets/css/main.css" rel="stylesheet" type="text/css"/>
layouts/partials
templates/partials
<!-- Nav -->
<nav>
<ul>
<li><a href="index.html">Coffee</a></li>
<li><a href="menu.html">Menu</a></li>
<li><a href="#">Coffee House</a></li>
<li><a href="#">Responsiblity</a></li>
<li><a href="#">Card</a></li>
<li><a href="#">Shop</a></li>
</ul>
</nav>
templates/index.hbs
---
title: Starbucks mockup website
published: true
---
<div>
<p> Sort of text or something! </p>
</div>
<img src="{{assets}}/potato.png" alt="Jason K"/>
templates/index.hbs
---
title: Starbucks mockup website
published: true
---
Title - page title
Published - does this page get processed?
Check out all the built in variables here: http://jekyllrb.com/docs/variables/
{{#if content-description}}
<meta name="description" content="{{content-description}}">
{{/if}}
---
title: Example Page
content-description: This page is an example
---
<div>
<p> Sort of text or something! </p>
</div>
<img src="{{assets}}/potato.png" alt="Jason K"/>
assemble: {
options: {
assets: "assets/",
data: "config.json",
ext: '.html',
flatten: true,
helpers: [
"handlebars-helpers"
],
contextual: {
dest: 'build/'
}
},
$ npm install live-server -g
$ cd build && live-server
and then there is
Check it out: https://github.com/assemble/assemble
By Ben Spoon