SlideShare a Scribd company logo
a static site generator
should be your next
language learning project
john sj anderson | @genehack | openwest 2018
hi, i’m
john.
a/k/a @genehack
2 — why&how2learn • #openwest18 • @genehack
custom software
development, training,
and technology
consulting
vp,technology
3 — why&how2learn • #openwest18 • @genehack
used to be a biologist,
sort of fell sideways into
IT, originally via Perl but
currently sort of
polyglot-ish
ex-biologist
perl tribe
polyglot coder
4 — why&how2learn • #openwest18 • @genehack
I submitted this talk with this
title, because Iʼve been telling
people this for the past couple
years -- “wanna learn a new
language? you should write a
static site generator” -- and I
kinda figured I should maybe
explain in more detail and maybe
try to justify it just a little bit
a static site generator
should be your next
language learning project
5 — why&how2learn • #openwest18 • @genehack
And during the course of
actually writing the talk -- as
frequently happens -- I figured
out that the title I pitched it
under kinda wasnʼt what the
talk wanted to be. This title is a
better description of the talk I
ended up actually writing.
the why and the how of
learning
a new programming language
6 — why&how2learn • #openwest18 • @genehack
one of the basic ideas
here is that continual
learning is super
important in our line of
work
premise:
lifelong
learning
is critical.
7 — why&how2learn • #openwest18 • @genehack
the only constant thing is people
telling you over and over that
the only constant thing is
change.
8 — why&how2learn • #openwest18 • @genehack
who here has heard this
before?
“learn at least one
new language
every year.”
— david thomas & andrew hunt, “the pragmatic programmer”, 1999
9 — why&how2learn • #openwest18 • @genehack
or, this more modern
variant...
“learn at least one new
javascript framework
every month.”
— me, this talk, right here right now
10 — why&how2learn • #openwest18 • @genehack
some of the languages i’ve “learned”
basic
pascal
applescript11 — why&how2learn • #openwest18 • @genehack
some of the languages i’ve “learned”
perl
ruby
python12 — why&how2learn • #openwest18 • @genehack
some of the languages i’ve “learned”
javascript
php
c13 — why&how2learn • #openwest18 • @genehack
some of the languages i’ve “learned”
lisp
clojure
scala14 — why&how2learn • #openwest18 • @genehack
some of the languages i’ve “learned”
node
swift
c♯15 — why&how2learn • #openwest18 • @genehack
how do you
learn a
language?16 — why&how2learn • #openwest18 • @genehack
readbooks and docs
17 — why&how2learn • #openwest18 • @genehack
dopractice exercises
18 — why&how2learn • #openwest18 • @genehack
whoʼs used exercism?
exercism.io
19 — why&how2learn • #openwest18 • @genehack
i'm trying to learn how to
garden and i'm starting
out by having a small
raised bed. you can see
here gesture that my
hand-sowing technique
still needs a lot of work
learning
projects
20 — why&how2learn • #openwest18 • @genehack
my language learning project of choice:
static site
generators
21 — why&how2learn • #openwest18 • @genehack
whatis a static site generator?
22 — why&how2learn • #openwest18 • @genehack
sometimes called 'ssg'
ssg23 — why&how2learn • #openwest18 • @genehack
static site generator just
takes some sort of input,
usually text files, and
then generates a web
site from those inputs
some inputs
➡a website24 — why&how2learn • #openwest18 • @genehack
this is strictly my definition, but to
my mind, once you have a database
involved, it's no longer a static site
generator -- databases push you
over the line into CMS territory
image source: https://i.pinimg.com/
736x/39/fc/
a1/39fca1f4193640cded1d84d0d7
c55c9c--disney-movies-disney-
cruiseplan.jpg
nodatabases!
25 — why&how2learn • #openwest18 • @genehack
can be very
simple
26 — why&how2learn • #openwest18 • @genehack
27 — why&how2learn • #openwest18 • @genehack
single
page28 — why&how2learn • #openwest18 • @genehack
part of a larger
site29 — why&how2learn • #openwest18 • @genehack
automatically
generated
every day
30 — why&how2learn • #openwest18 • @genehack
based on
simple
structured data file
31 — why&how2learn • #openwest18 • @genehack
this 'open all' button down
here will spawn a new tab for
each one of these links. so
the SSG code here is turning
the data not only into HTML,
but into a list of URLs in some
javascript code that runs
when you click that button
32 — why&how2learn • #openwest18 • @genehack
wrote ~10-15
years ago
33 — why&how2learn • #openwest18 • @genehack
ssgs can also be
kindacomplicated
34 — why&how2learn • #openwest18 • @genehack
35 — why&how2learn • #openwest18 • @genehack
iinteractive.com/notebook
36 — why&how2learn • #openwest18 • @genehack
company
site37 — why&how2learn • #openwest18 • @genehack
jekyll
^ hugo
^ hid
weblog
with tags, archive, et cetera
38 — why&how2learn • #openwest18 • @genehack
so why are
ssgs great for
learning?
39 — why&how2learn • #openwest18 • @genehack
thereʼs a quick early
payoff and then thereʼs
a lot of potential to go
other places
iterative
& incremental
40 — why&how2learn • #openwest18 • @genehack
think about what you
need to do
they hit on all the
classics
41 — why&how2learn • #openwest18 • @genehack
basic “hello world” ssg:
turn 1 input file into 1
web page
hello
world
as a ssg
42 — why&how2learn • #openwest18 • @genehack
o hai
there
43 — why&how2learn • #openwest18 • @genehack
(at this stage, you can
cheat and hardcode
most of the HTML in
print statements)
1. read input from file
2. process the input
3. write output to file
44 — why&how2learn • #openwest18 • @genehack
45 — why&how2learn • #openwest18 • @genehack
hello world!
46 — why&how2learn • #openwest18 • @genehack
#! /usr/bin/env perl
use strict;
use warnings;
open( my $in , '<' , 'index.txt' )
or die "cannot read index.txt: $!";
my $input;
while( my $line = <$in> ) {
$input .= $line;
}
close( $in );
my $top = <<EOF;
<!doctype html>
<html>
<head><title>$input</title><head>
<body><h1>
EOF
my $bottom = <<EOF;
</h1></body>
</html>
EOF
my $output = $top . $input . $bottom;
open( my $out , '>' , 'index.html')
or die "cannot write to index.html: $!";
print $out $output;
close( $out );
47 — why&how2learn • #openwest18 • @genehack
open( my $in , '<' , 'index.txt' )
or die "cannot read index.txt: $!";
my $input;
while( my $line = <$in> ) {
$input .= $line;
}
close( $in );
48 — why&how2learn • #openwest18 • @genehack
my $top = <<EOF;
<!doctype html>
<html>
<head><title>$input</title><head>
<body><h1>
EOF
my $bottom = <<EOF;
</h1></body>
</html>
EOF
my $output = $top . $input . $bottom;
49 — why&how2learn • #openwest18 • @genehack
open( my $out , '>' , 'index.html')
or die "cannot write to index.html: $!";
print $out $output;
close( $out );
50 — why&how2learn • #openwest18 • @genehack
hello world!
51 — why&how2learn • #openwest18 • @genehack
52 — why&how2learn • #openwest18 • @genehack
let’s
pause
here53 — why&how2learn • #openwest18 • @genehack
1. read input from file
2. process the input
3. write output to file
54 — why&how2learn • #openwest18 • @genehack
in those 3 steps we just did a
whole bunch
of stuff
55 — why&how2learn • #openwest18 • @genehack
writing some code
andgetting it to build/run
56 — why&how2learn • #openwest18 • @genehack
reading & writing
files57 — why&how2learn • #openwest18 • @genehack
(which probably means
figuring out where to find
documentation)
58 — why&how2learn • #openwest18 • @genehack
getting data
from a file into a
variable59 — why&how2learn • #openwest18 • @genehack
interpolating
a variable into output
60 — why&how2learn • #openwest18 • @genehack
o/
yay!
61 — why&how2learn • #openwest18 • @genehack
next:adding yaml
front matter62 — why&how2learn • #openwest18 • @genehack
aside:don’t know from
yaml?
see this talk tomorrow!
63 — why&how2learn • #openwest18 • @genehack
title: Hello World!
---
hello again world!
64 — why&how2learn • #openwest18 • @genehack
#! /usr/bin/env perl
use strict;
use warnings;
use YAML::XS;
open( my $in , '<' , 'index2.txt' )
or die "cannot read index.txt: $!";
my $lines;
while ( my $line = <$in> ) { $lines .= $line }
close( $in );
my( $yaml, $content ) = split( /^---$/m, $lines , 2 );
my $front = Load $yaml;
my $title = $front->{title};
my $top = <<EOF;
<!doctype html>
<html>
<head><title>$title</title><head>
<body>
EOF
my $bottom = <<EOF;
</body>
</html>
EOF
my $output = $top . $content . $bottom;
open( my $out , '>' , 'index.html')
or die "cannot write to index.html: $!";
print $out $output;
close( $out );
65 — why&how2learn • #openwest18 • @genehack
open( my $in , '<' , 'index2.txt' )
or die "cannot read index.txt: $!";
my $lines;
while ( my $line = <$in> ) { $lines .= $line }
close( $in );
66 — why&how2learn • #openwest18 • @genehack
my( $yaml, $content ) = split( /^---$/m, $lines , 2 );
my $front = Load $yaml;
my $title = $front->{title};
67 — why&how2learn • #openwest18 • @genehack
my $top = <<EOF;
<!doctype html>
<html>
<head><title>$title</title><head>
<body>
EOF
my $bottom = <<EOF;
</body>
</html>
EOF
my $output = $top . $content . $bottom;
68 — why&how2learn • #openwest18 • @genehack
open( my $out , '>' , 'index.html')
or die "cannot write to index.html: $!";
print $out $output;
close( $out );
69 — why&how2learn • #openwest18 • @genehack
70 — why&how2learn • #openwest18 • @genehack
and thatʼs when you
need to deal with loops
and getting all the files
out of a directory, maybe
skipping over some files,
recursion into the
directory, etc.
next:two input files
71 — why&how2learn • #openwest18 • @genehack
this is also when youʼre
going to want a
templating engine
because hardcoding
html in your code is only
going to take you so far
as well:
templates!
72 — why&how2learn • #openwest18 • @genehack
which probably means
figuring out how to
install libraries/
packages/deps/
whatever the language
calls them
which means:
figuring out
packages
73 — why&how2learn • #openwest18 • @genehack
(note: writing your own
templating system is a
different learning
project)
note:probably don’t
write your own template engine
74 — why&how2learn • #openwest18 • @genehack
also:loops & conditional logic
oh my75 — why&how2learn • #openwest18 • @genehack
after
that…76 — why&how2learn • #openwest18 • @genehack
the sky’s
the limit
77 — why&how2learn • #openwest18 • @genehack
support for blog-like workflows
(which means 1 input file
generating more than one page
and 1 page being generated
from more than one input file)
which means tracking more
internal state during program
execution, which means diving
into data structures
add a
weblog78 — why&how2learn • #openwest18 • @genehack
folding in other
processing (e.g., SASS -
> CSS processing)
which means figuring out
how to invoke and
manage external
processes
add other
processors
79 — why&how2learn • #openwest18 • @genehack
a real CLI app with sub-
commands -- more
library usage! code
organization!
add a subcmd-style
app80 — why&how2learn • #openwest18 • @genehack
and then you can get
fancy…
81 — why&how2learn • #openwest18 • @genehack
http
server82 — why&how2learn • #openwest18 • @genehack
automatically
rebuild output when input is
modified
83 — why&how2learn • #openwest18 • @genehack
and the list can go on
and on
only rebuild output when
necessary
84 — why&how2learn • #openwest18 • @genehack
finally
when you think you’re “done”…
85 — why&how2learn • #openwest18 • @genehack
once youʼve done a
good chunk, go back
and rewrite the earlier
bits to be more
idiomatic
go back & take another
look
86 — why&how2learn • #openwest18 • @genehack
donʼt just write your
favorite language in the
new language, figure
out how the new
language is supposed
to work
don’twrite your $oldlangin your
$newlang.
87 — why&how2learn • #openwest18 • @genehack
so, to
sum up:88 — why&how2learn • #openwest18 • @genehack
continuing to learn
is vital!
89 — why&how2learn • #openwest18 • @genehack
figure out
how to make that happen
90 — why&how2learn • #openwest18 • @genehack
both in terms of
“maintain interest in it”
91 — why&how2learn • #openwest18 • @genehack
& in terms of
“be good at it”
92 — why&how2learn • #openwest18 • @genehack
maybe an SSG isnʼt the right
learning project for you,
maybe projects arenʼt the
right learning mechanism for
you -- but you need to figure
out what the right mechanism,
the right project is, so you can
keep on learning
disclaimer:
this talk is based on
my opinions and experiences
93 — why&how2learn • #openwest18 • @genehack
your mileage
will vary
94 — why&how2learn • #openwest18 • @genehack
thanks to organizers,
attendees
thanks!
95 — why&how2learn • #openwest18 • @genehack
special thanks
@qedunham
96 — why&how2learn • #openwest18 • @genehack
special thanks
@vmbrasseur
@garethgreenaway
97 — why&how2learn • #openwest18 • @genehack
openwest
organizers
98 — why&how2learn • #openwest18 • @genehack
you!
99 — why&how2learn • #openwest18 • @genehack
A static site generator should be your next language learning project
questions?
101 — why&how2learn • #openwest18 • @genehack
questions?
102 — why&how2learn • #openwest18 • @genehack

More Related Content

PDF
A static site generator should be your next language learning project
PDF
RESTFul API Design and Documentation - an Introduction
PDF
Gem christmas calendar
PDF
PDF
Front End on Rails
PDF
Kiran karnad rtc2014 ghdb-final
KEY
Rails by example
PDF
google dork.pdf
A static site generator should be your next language learning project
RESTFul API Design and Documentation - an Introduction
Gem christmas calendar
Front End on Rails
Kiran karnad rtc2014 ghdb-final
Rails by example
google dork.pdf

Similar to A static site generator should be your next language learning project (20)

PDF
Theme like a monster #ddceu
PPTX
Subtle Encipherment Hall
ZIP
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
PDF
A static site generator should be your next language learning project
PDF
Bangla html
PDF
Grok Drupal (7) Theming - 2011 Feb update
PDF
Understanding & Facilitating Semantic Search - #SearchFest 2016
ZIP
Sphinx on Rails
PDF
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
KEY
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
PPT
WordPress Development Confoo 2010
PDF
Cocoa pods iOSDevUK 14 talk: managing your libraries
KEY
Javascript done right - Open Web Camp III
PPTX
Twas the night before Malware...
PDF
You got chocolate in my peanut butter! .NET on Mac & Linux
PDF
Grok Drupal (7) Theming
PPTX
Apex & jQuery Mobile
PPT
Php introduction
PDF
Golang and Domain Specific Languages - Lorenzo Fontana - Codemotion Rome 2017
ODP
SlideShare Instant
Theme like a monster #ddceu
Subtle Encipherment Hall
Deliverance: Plone theming without the learning curve from Plone Symposium Ea...
A static site generator should be your next language learning project
Bangla html
Grok Drupal (7) Theming - 2011 Feb update
Understanding & Facilitating Semantic Search - #SearchFest 2016
Sphinx on Rails
Howdoesgettemplatepartworksintwentytentheme 110123234953-phpapp02
Joomla! Day Chicago 2011 - Templating the right way - Jonathan Shroyer
WordPress Development Confoo 2010
Cocoa pods iOSDevUK 14 talk: managing your libraries
Javascript done right - Open Web Camp III
Twas the night before Malware...
You got chocolate in my peanut butter! .NET on Mac & Linux
Grok Drupal (7) Theming
Apex & jQuery Mobile
Php introduction
Golang and Domain Specific Languages - Lorenzo Fontana - Codemotion Rome 2017
SlideShare Instant
Ad

More from John Anderson (20)

PDF
#speakerlife
PDF
Introduction to Git (even for non-developers)
PDF
Logs are-magic-devfestweekend2018
PDF
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
PDF
Do you want to be right or do you want to WIN?
PDF
An Introduction to Git (even for non-developers)
PDF
Old Dogs & New Tricks: What's New with Perl5 This Century
PDF
Introduction to Git (even for non-developers!)
PDF
Introduction to Git for Non-Developers
PDF
A Modest Introduction To Swift
PDF
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
PDF
JSON Web Tokens Will Improve Your Life
PDF
Old Dogs & New Tricks: What's New With Perl5 This Century
PDF
A Modest Introduction to Swift
PDF
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
PDF
Friends Don't Let Friends Browse Unencrypted: Running a VPN for friends and f...
PDF
A Modest Introduction To Swift
PDF
Logs Are Magic! Why git workflows & commit structure should matter to you
PDF
#speakerlife
PDF
JSON Web Tokens Will Improve Your Life
#speakerlife
Introduction to Git (even for non-developers)
Logs are-magic-devfestweekend2018
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
Do you want to be right or do you want to WIN?
An Introduction to Git (even for non-developers)
Old Dogs & New Tricks: What's New with Perl5 This Century
Introduction to Git (even for non-developers!)
Introduction to Git for Non-Developers
A Modest Introduction To Swift
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
JSON Web Tokens Will Improve Your Life
Old Dogs & New Tricks: What's New With Perl5 This Century
A Modest Introduction to Swift
Logs Are Magic: Why Git Workflows and Commit Structure Should Matter To You
Friends Don't Let Friends Browse Unencrypted: Running a VPN for friends and f...
A Modest Introduction To Swift
Logs Are Magic! Why git workflows & commit structure should matter to you
#speakerlife
JSON Web Tokens Will Improve Your Life
Ad

Recently uploaded (20)

PPTX
Transform Your Business with a Software ERP System
PPTX
ai tools demonstartion for schools and inter college
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
medical staffing services at VALiNTRY
PDF
System and Network Administraation Chapter 3
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
System and Network Administration Chapter 2
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
top salesforce developer skills in 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Transform Your Business with a Software ERP System
ai tools demonstartion for schools and inter college
Reimagine Home Health with the Power of Agentic AI​
How to Migrate SBCGlobal Email to Yahoo Easily
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
medical staffing services at VALiNTRY
System and Network Administraation Chapter 3
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
L1 - Introduction to python Backend.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Operating system designcfffgfgggggggvggggggggg
Odoo POS Development Services by CandidRoot Solutions
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
System and Network Administration Chapter 2
Understanding Forklifts - TECH EHS Solution
Design an Analysis of Algorithms I-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle
top salesforce developer skills in 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

A static site generator should be your next language learning project

  • 1. a static site generator should be your next language learning project john sj anderson | @genehack | openwest 2018
  • 2. hi, i’m john. a/k/a @genehack 2 — why&how2learn • #openwest18 • @genehack
  • 3. custom software development, training, and technology consulting vp,technology 3 — why&how2learn • #openwest18 • @genehack
  • 4. used to be a biologist, sort of fell sideways into IT, originally via Perl but currently sort of polyglot-ish ex-biologist perl tribe polyglot coder 4 — why&how2learn • #openwest18 • @genehack
  • 5. I submitted this talk with this title, because Iʼve been telling people this for the past couple years -- “wanna learn a new language? you should write a static site generator” -- and I kinda figured I should maybe explain in more detail and maybe try to justify it just a little bit a static site generator should be your next language learning project 5 — why&how2learn • #openwest18 • @genehack
  • 6. And during the course of actually writing the talk -- as frequently happens -- I figured out that the title I pitched it under kinda wasnʼt what the talk wanted to be. This title is a better description of the talk I ended up actually writing. the why and the how of learning a new programming language 6 — why&how2learn • #openwest18 • @genehack
  • 7. one of the basic ideas here is that continual learning is super important in our line of work premise: lifelong learning is critical. 7 — why&how2learn • #openwest18 • @genehack
  • 8. the only constant thing is people telling you over and over that the only constant thing is change. 8 — why&how2learn • #openwest18 • @genehack
  • 9. who here has heard this before? “learn at least one new language every year.” — david thomas & andrew hunt, “the pragmatic programmer”, 1999 9 — why&how2learn • #openwest18 • @genehack
  • 10. or, this more modern variant... “learn at least one new javascript framework every month.” — me, this talk, right here right now 10 — why&how2learn • #openwest18 • @genehack
  • 11. some of the languages i’ve “learned” basic pascal applescript11 — why&how2learn • #openwest18 • @genehack
  • 12. some of the languages i’ve “learned” perl ruby python12 — why&how2learn • #openwest18 • @genehack
  • 13. some of the languages i’ve “learned” javascript php c13 — why&how2learn • #openwest18 • @genehack
  • 14. some of the languages i’ve “learned” lisp clojure scala14 — why&how2learn • #openwest18 • @genehack
  • 15. some of the languages i’ve “learned” node swift c♯15 — why&how2learn • #openwest18 • @genehack
  • 16. how do you learn a language?16 — why&how2learn • #openwest18 • @genehack
  • 17. readbooks and docs 17 — why&how2learn • #openwest18 • @genehack
  • 18. dopractice exercises 18 — why&how2learn • #openwest18 • @genehack
  • 19. whoʼs used exercism? exercism.io 19 — why&how2learn • #openwest18 • @genehack
  • 20. i'm trying to learn how to garden and i'm starting out by having a small raised bed. you can see here gesture that my hand-sowing technique still needs a lot of work learning projects 20 — why&how2learn • #openwest18 • @genehack
  • 21. my language learning project of choice: static site generators 21 — why&how2learn • #openwest18 • @genehack
  • 22. whatis a static site generator? 22 — why&how2learn • #openwest18 • @genehack
  • 23. sometimes called 'ssg' ssg23 — why&how2learn • #openwest18 • @genehack
  • 24. static site generator just takes some sort of input, usually text files, and then generates a web site from those inputs some inputs ➡a website24 — why&how2learn • #openwest18 • @genehack
  • 25. this is strictly my definition, but to my mind, once you have a database involved, it's no longer a static site generator -- databases push you over the line into CMS territory image source: https://i.pinimg.com/ 736x/39/fc/ a1/39fca1f4193640cded1d84d0d7 c55c9c--disney-movies-disney- cruiseplan.jpg nodatabases! 25 — why&how2learn • #openwest18 • @genehack
  • 26. can be very simple 26 — why&how2learn • #openwest18 • @genehack
  • 27. 27 — why&how2learn • #openwest18 • @genehack
  • 28. single page28 — why&how2learn • #openwest18 • @genehack
  • 29. part of a larger site29 — why&how2learn • #openwest18 • @genehack
  • 30. automatically generated every day 30 — why&how2learn • #openwest18 • @genehack
  • 31. based on simple structured data file 31 — why&how2learn • #openwest18 • @genehack
  • 32. this 'open all' button down here will spawn a new tab for each one of these links. so the SSG code here is turning the data not only into HTML, but into a list of URLs in some javascript code that runs when you click that button 32 — why&how2learn • #openwest18 • @genehack
  • 33. wrote ~10-15 years ago 33 — why&how2learn • #openwest18 • @genehack
  • 34. ssgs can also be kindacomplicated 34 — why&how2learn • #openwest18 • @genehack
  • 35. 35 — why&how2learn • #openwest18 • @genehack
  • 36. iinteractive.com/notebook 36 — why&how2learn • #openwest18 • @genehack
  • 37. company site37 — why&how2learn • #openwest18 • @genehack
  • 38. jekyll ^ hugo ^ hid weblog with tags, archive, et cetera 38 — why&how2learn • #openwest18 • @genehack
  • 39. so why are ssgs great for learning? 39 — why&how2learn • #openwest18 • @genehack
  • 40. thereʼs a quick early payoff and then thereʼs a lot of potential to go other places iterative & incremental 40 — why&how2learn • #openwest18 • @genehack
  • 41. think about what you need to do they hit on all the classics 41 — why&how2learn • #openwest18 • @genehack
  • 42. basic “hello world” ssg: turn 1 input file into 1 web page hello world as a ssg 42 — why&how2learn • #openwest18 • @genehack
  • 43. o hai there 43 — why&how2learn • #openwest18 • @genehack
  • 44. (at this stage, you can cheat and hardcode most of the HTML in print statements) 1. read input from file 2. process the input 3. write output to file 44 — why&how2learn • #openwest18 • @genehack
  • 45. 45 — why&how2learn • #openwest18 • @genehack
  • 46. hello world! 46 — why&how2learn • #openwest18 • @genehack
  • 47. #! /usr/bin/env perl use strict; use warnings; open( my $in , '<' , 'index.txt' ) or die "cannot read index.txt: $!"; my $input; while( my $line = <$in> ) { $input .= $line; } close( $in ); my $top = <<EOF; <!doctype html> <html> <head><title>$input</title><head> <body><h1> EOF my $bottom = <<EOF; </h1></body> </html> EOF my $output = $top . $input . $bottom; open( my $out , '>' , 'index.html') or die "cannot write to index.html: $!"; print $out $output; close( $out ); 47 — why&how2learn • #openwest18 • @genehack
  • 48. open( my $in , '<' , 'index.txt' ) or die "cannot read index.txt: $!"; my $input; while( my $line = <$in> ) { $input .= $line; } close( $in ); 48 — why&how2learn • #openwest18 • @genehack
  • 49. my $top = <<EOF; <!doctype html> <html> <head><title>$input</title><head> <body><h1> EOF my $bottom = <<EOF; </h1></body> </html> EOF my $output = $top . $input . $bottom; 49 — why&how2learn • #openwest18 • @genehack
  • 50. open( my $out , '>' , 'index.html') or die "cannot write to index.html: $!"; print $out $output; close( $out ); 50 — why&how2learn • #openwest18 • @genehack
  • 51. hello world! 51 — why&how2learn • #openwest18 • @genehack
  • 52. 52 — why&how2learn • #openwest18 • @genehack
  • 53. let’s pause here53 — why&how2learn • #openwest18 • @genehack
  • 54. 1. read input from file 2. process the input 3. write output to file 54 — why&how2learn • #openwest18 • @genehack
  • 55. in those 3 steps we just did a whole bunch of stuff 55 — why&how2learn • #openwest18 • @genehack
  • 56. writing some code andgetting it to build/run 56 — why&how2learn • #openwest18 • @genehack
  • 57. reading & writing files57 — why&how2learn • #openwest18 • @genehack
  • 58. (which probably means figuring out where to find documentation) 58 — why&how2learn • #openwest18 • @genehack
  • 59. getting data from a file into a variable59 — why&how2learn • #openwest18 • @genehack
  • 60. interpolating a variable into output 60 — why&how2learn • #openwest18 • @genehack
  • 61. o/ yay! 61 — why&how2learn • #openwest18 • @genehack
  • 62. next:adding yaml front matter62 — why&how2learn • #openwest18 • @genehack
  • 63. aside:don’t know from yaml? see this talk tomorrow! 63 — why&how2learn • #openwest18 • @genehack
  • 64. title: Hello World! --- hello again world! 64 — why&how2learn • #openwest18 • @genehack
  • 65. #! /usr/bin/env perl use strict; use warnings; use YAML::XS; open( my $in , '<' , 'index2.txt' ) or die "cannot read index.txt: $!"; my $lines; while ( my $line = <$in> ) { $lines .= $line } close( $in ); my( $yaml, $content ) = split( /^---$/m, $lines , 2 ); my $front = Load $yaml; my $title = $front->{title}; my $top = <<EOF; <!doctype html> <html> <head><title>$title</title><head> <body> EOF my $bottom = <<EOF; </body> </html> EOF my $output = $top . $content . $bottom; open( my $out , '>' , 'index.html') or die "cannot write to index.html: $!"; print $out $output; close( $out ); 65 — why&how2learn • #openwest18 • @genehack
  • 66. open( my $in , '<' , 'index2.txt' ) or die "cannot read index.txt: $!"; my $lines; while ( my $line = <$in> ) { $lines .= $line } close( $in ); 66 — why&how2learn • #openwest18 • @genehack
  • 67. my( $yaml, $content ) = split( /^---$/m, $lines , 2 ); my $front = Load $yaml; my $title = $front->{title}; 67 — why&how2learn • #openwest18 • @genehack
  • 68. my $top = <<EOF; <!doctype html> <html> <head><title>$title</title><head> <body> EOF my $bottom = <<EOF; </body> </html> EOF my $output = $top . $content . $bottom; 68 — why&how2learn • #openwest18 • @genehack
  • 69. open( my $out , '>' , 'index.html') or die "cannot write to index.html: $!"; print $out $output; close( $out ); 69 — why&how2learn • #openwest18 • @genehack
  • 70. 70 — why&how2learn • #openwest18 • @genehack
  • 71. and thatʼs when you need to deal with loops and getting all the files out of a directory, maybe skipping over some files, recursion into the directory, etc. next:two input files 71 — why&how2learn • #openwest18 • @genehack
  • 72. this is also when youʼre going to want a templating engine because hardcoding html in your code is only going to take you so far as well: templates! 72 — why&how2learn • #openwest18 • @genehack
  • 73. which probably means figuring out how to install libraries/ packages/deps/ whatever the language calls them which means: figuring out packages 73 — why&how2learn • #openwest18 • @genehack
  • 74. (note: writing your own templating system is a different learning project) note:probably don’t write your own template engine 74 — why&how2learn • #openwest18 • @genehack
  • 75. also:loops & conditional logic oh my75 — why&how2learn • #openwest18 • @genehack
  • 76. after that…76 — why&how2learn • #openwest18 • @genehack
  • 77. the sky’s the limit 77 — why&how2learn • #openwest18 • @genehack
  • 78. support for blog-like workflows (which means 1 input file generating more than one page and 1 page being generated from more than one input file) which means tracking more internal state during program execution, which means diving into data structures add a weblog78 — why&how2learn • #openwest18 • @genehack
  • 79. folding in other processing (e.g., SASS - > CSS processing) which means figuring out how to invoke and manage external processes add other processors 79 — why&how2learn • #openwest18 • @genehack
  • 80. a real CLI app with sub- commands -- more library usage! code organization! add a subcmd-style app80 — why&how2learn • #openwest18 • @genehack
  • 81. and then you can get fancy… 81 — why&how2learn • #openwest18 • @genehack
  • 82. http server82 — why&how2learn • #openwest18 • @genehack
  • 83. automatically rebuild output when input is modified 83 — why&how2learn • #openwest18 • @genehack
  • 84. and the list can go on and on only rebuild output when necessary 84 — why&how2learn • #openwest18 • @genehack
  • 85. finally when you think you’re “done”… 85 — why&how2learn • #openwest18 • @genehack
  • 86. once youʼve done a good chunk, go back and rewrite the earlier bits to be more idiomatic go back & take another look 86 — why&how2learn • #openwest18 • @genehack
  • 87. donʼt just write your favorite language in the new language, figure out how the new language is supposed to work don’twrite your $oldlangin your $newlang. 87 — why&how2learn • #openwest18 • @genehack
  • 88. so, to sum up:88 — why&how2learn • #openwest18 • @genehack
  • 89. continuing to learn is vital! 89 — why&how2learn • #openwest18 • @genehack
  • 90. figure out how to make that happen 90 — why&how2learn • #openwest18 • @genehack
  • 91. both in terms of “maintain interest in it” 91 — why&how2learn • #openwest18 • @genehack
  • 92. & in terms of “be good at it” 92 — why&how2learn • #openwest18 • @genehack
  • 93. maybe an SSG isnʼt the right learning project for you, maybe projects arenʼt the right learning mechanism for you -- but you need to figure out what the right mechanism, the right project is, so you can keep on learning disclaimer: this talk is based on my opinions and experiences 93 — why&how2learn • #openwest18 • @genehack
  • 94. your mileage will vary 94 — why&how2learn • #openwest18 • @genehack
  • 95. thanks to organizers, attendees thanks! 95 — why&how2learn • #openwest18 • @genehack
  • 96. special thanks @qedunham 96 — why&how2learn • #openwest18 • @genehack
  • 97. special thanks @vmbrasseur @garethgreenaway 97 — why&how2learn • #openwest18 • @genehack
  • 98. openwest organizers 98 — why&how2learn • #openwest18 • @genehack
  • 99. you! 99 — why&how2learn • #openwest18 • @genehack
  • 101. questions? 101 — why&how2learn • #openwest18 • @genehack
  • 102. questions? 102 — why&how2learn • #openwest18 • @genehack