Top Banner
Getting Star ted with Jek yll Brian Rinaldi @remotesynth
37

Getting Started with Jekyll for Static Sites

Apr 13, 2017

Download

Internet

FITC
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Getting Started with Jekyll for Static Sites

Getting Started with JekyllBrian Rinaldi@remotesynth

Page 2: Getting Started with Jekyll for Static Sites

A Little Bit About Me

4 Developer Programs Manager for Progress (aka Telerik)

4 Author of the Static Site Generators report (free from O'Reilly)

4 Co-author (with Raymond Camden) of the upcoming book "Working with Static Site Generators" (also from O'Reilly)

Page 3: Getting Started with Jekyll for Static Sites

Why Static?

Page 4: Getting Started with Jekyll for Static Sites

Fast

Page 5: Getting Started with Jekyll for Static Sites

Secure

Page 6: Getting Started with Jekyll for Static Sites

Flexible

Page 7: Getting Started with Jekyll for Static Sites

Tedious?

Page 8: Getting Started with Jekyll for Static Sites

What's a Static Site Generator?

Page 9: Getting Started with Jekyll for Static Sites
Page 10: Getting Started with Jekyll for Static Sites

There are 4371 to choose from!4 Jekyll (Ruby)

4 Middleman (Ruby)

4 Hugo (Go)

4 Hexo (JavaScript)

4 Pelican (Python)

1 Source - https://staticsitegenerators.net/

Page 11: Getting Started with Jekyll for Static Sites

There are 437 to choose from!4 Wintersmith (JavaScript)

4 Metalsmith (JavaScript)

4 Harp (JavaScript)

4 DocPad (CoffeeScript)

4 Gatsby (JavaScript)

4 ...etc.

Page 12: Getting Started with Jekyll for Static Sites

Why Jekyll?

Page 13: Getting Started with Jekyll for Static Sites

Why Jekyll?4 Most mature

4 Biggest community

4 Good documentation

4 Broadest support

4 You (probably) don't need to know Ruby

Page 14: Getting Started with Jekyll for Static Sites

Getting Set UpPrerequisites

4 Ruby

4 RubyGems

4 Mac OS or Linux

Page 15: Getting Started with Jekyll for Static Sites

What?! No Windows?

Page 16: Getting Started with Jekyll for Static Sites

Getting Set UpOnce you have the prereqs...

gem install jekyll

Page 17: Getting Started with Jekyll for Static Sites

Creating a New Sitejekyll new teentitansgofansitecd teentitansgofansitejekyll serve

Page 18: Getting Started with Jekyll for Static Sites

Basic Configurationtitle: My Teen Titans Go! Fan Siteemail: [email protected]: > # this means to ignore newlines until "baseurl:" Because I am a huge dork who thinks Teen Titans Go! is hilarious.baseurl: "" # the subpath of your site, e.g. /blogurl: "" # the base hostname & protocol for your sitetwitter_username: remotesynthgithub_username: remotesynth # you can add any metadata you want

Page 19: Getting Started with Jekyll for Static Sites

Customizing Your SiteBy default Jekyll uses the Liquid templating language (with added filters/tags)

Page 20: Getting Started with Jekyll for Static Sites

Liquid Basics

Page 21: Getting Started with Jekyll for Static Sites

Output Data

Straight output of a Jekyll variable

<h2>{{ page.title }}</h2>

...or use a filter...

<p>Posted {{ post.date | date: "%b %-d, %Y" }}</p>

Page 22: Getting Started with Jekyll for Static Sites

Include Another Template

Useful for breaking up template files...

{% include header.html %}

Page 23: Getting Started with Jekyll for Static Sites

Conditionals

{% if page.url == "/index.html" %}<!-- Banner --> <section id="banner"> <header> <h2>Explore the Land of Ooo...</h2> <p>...and its many kingdoms!</p> </header> </section>{% endif %}

Page 24: Getting Started with Jekyll for Static Sites

Loops

{% for post in site.posts limit:5 offset:2 %} <li> <span class="date">{{ post.date | date: "%b %-d, %Y" }}</strong></span> <h3><a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a></h3> <p>{{ post.excerpt }}</p> </li>{% endfor %}

Page 25: Getting Started with Jekyll for Static Sites

Adding Pages/Posts

Page 26: Getting Started with Jekyll for Static Sites

Adding Pages/PostsPages can be Markdown or HTML and can go anywhere in the site structure.

Posts can also be Markdown or HTML, but must go in _posts and follow a naming convention of YEAR-MONTH-DAY-title.MARKUP. So...

2016-10-03-the-best-session-webu-was-jekyll.md2016-10-04-nevermind-i-take-it-back.html

^ Pages do not need a particular naming

Page 27: Getting Started with Jekyll for Static Sites

FrontMatter...is YAML-formatted metadata at the start of a file.---layout: post # required for poststitle: "Raven is the best Teen Titan" # required for postsdate: 2015-10-03 11:00:00 # required for postscategories: titans charactersfamous_quote: "Azarath... Metrion... ZINTHOS!" # I can add whatever metdata I want---

Page 28: Getting Started with Jekyll for Static Sites

Data

Page 29: Getting Started with Jekyll for Static Sites

DataYAML, JSON or CSV data can be placed in the _data directory.

Accessed via site.data.[data_filename] variable.

Page 30: Getting Started with Jekyll for Static Sites

Deployment

Page 31: Getting Started with Jekyll for Static Sites

Deploymentjekyll build

4 FTP

4 Glynn

4 GitHub Pages

4 Netlify

4 So many other options...

Page 32: Getting Started with Jekyll for Static Sites

Jekyll Adminhttps://jekyll.github.io/jekyll-admin/

Page 33: Getting Started with Jekyll for Static Sites

More Examples4 Static Site Samples

Same site built with 10+ engineshttps://github.com/remotesynth/Static-Site-Samples

4 Getting Started with Jekyll (article)http://developer.telerik.com/featured/getting-started-with-jekyll/

Page 34: Getting Started with Jekyll for Static Sites

What Kinds of Sites Work as Static Sites?

Page 35: Getting Started with Jekyll for Static Sites

Questions?

Page 36: Getting Started with Jekyll for Static Sites

Win a MiP Robot!

Page 37: Getting Started with Jekyll for Static Sites

Win a MiP Robot!