Technical Blogging with Jekyll

A presentation at Codeland in May 2018 in New York, NY, USA by Monica Powell

Slide 1

Slide 1

CODELAND 2018 | BY MONICA POWELL CREATE A BLOG WITH JEKYLL

Slide 2

Slide 2

2 CREATE A BLOG WITH JEKYLL FOLLOW ALONG ▸ Demo Site: ▸ https://m0nica.github.io/dactl/ ▸ GitHub Repository: ▸ https://github.com/M0nica/dactl ▸ Slides: ▸ http://aboutmonica.com/codeland/jekyll.pdf Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 3

Slide 3

3 CREATE A BLOG WITH JEKYLL ABOUT US! Monica Powell, I’m a long-time #CodeNewbie! I currently lead e-mail marketing at Jopwell and periodically write for FreeCodeCamp, Hacker Noon and Code Like A Girl. ! Twitter: @waterproofheart Nia Murrell is a self-taught developer and long-time coding enthusiast. She is an active member of the L.A. tech community who volunteers as a developer for small businesses and as a TA for the L.A. chapter of Girl Develop It. 🔗 www.aboutmonica.com/ 🔗 https://dev.niamurrell.com Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 4

Slide 4

4 CREATE A BLOG WITH JEKYLL ICE BREAKER - WHY ARE YOU HERE? ▸ Name ▸ Why do you want to create a technical blog? What are you hoping to gain from having a blog? Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 5

Slide 5

5 CREATE A BLOG WITH JEKYLL SOME OF THE TOPICS WE WILL COVER 1. Examples of Jekyll Sites 7. Creating a Post 2. Static vs. Dynamic Sites 8. Adding images 3. Jekyll Overview 9. Adding Social Icons 4. Installing Jekyll 5. Jekyll Project Structure 6. Editing Sitewide Variables Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 6

Slide 6

Image Source: GitLab 6 2) STATIC VS DYNAMIC SITES STATIC VS DYNAMIC WEBSITES Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 7

Slide 7

  1. JEKYLL OVERVIEW WHAT IS JEKYLL?

Slide 8

Slide 8

8

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Documentation Sites ▸ Ruby https://www.ruby-lang.org/en/ ▸ Bootstrap https://getbootstrap.com/ ▸ Blogs/Personal Websites ▸ https://zachholman.com ▸ www.datalogues.com (Monica’s blog!) ▸ https://www.chenhuijing.com/ Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 9

Slide 9

9

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Ruby documentation https://www.ruby-lang.org/en/ ▸ Bootstrap documentation https://getbootstrap.com/ ▸ Blog/Personal Website ▸ https://zachholman.com ▸ www.datalogues.com ▸ https://www.chenhuijing.com/#%F0%9F%8E%AE Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 10

Slide 10

10

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Ruby documentation https://www.ruby-lang.org/en/ ▸ Bootstrap documentation https://getbootstrap.com/ ▸ Blog/Personal Website ▸ https://zachholman.com ▸ www.datalogues.com ▸ https://www.chenhuijing.com/#%F0%9F%8E%AE Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 11

Slide 11

11

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Ruby documentation https://www.ruby-lang.org/en/ ▸ Bootstrap documentation https://getbootstrap.com/ ▸ Blog/Personal Website ▸ https://zachholman.com ▸ www.datalogues.com ▸ https://www.chenhuijing.com/#%F0%9F%8E%AE Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 12

Slide 12

12

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Ruby documentation https://www.ruby-lang.org/en/ ▸ Bootstrap documentation https://getbootstrap.com/ ▸ Blog/Personal Website ▸ https://zachholman.com ▸ www.datalogues.com ▸ https://www.chenhuijing.com/#%F0%9F%8E%AE Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 13

Slide 13

13

  1. EXAMPLES OF JEKYLL SITES WEBSITES POWERED BY JEKYLL ▸ Ruby documentation https://www.ruby-lang.org/en/ ▸ Bootstrap documentation https://getbootstrap.com/ ▸ Blog/Personal Website ▸ https://zachholman.com ▸ www.datalogues.com ▸ https://www.chenhuijing.com/#%F0%9F%8E%AE Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 14

Slide 14

INSTALLATION FEST

Slide 15

Slide 15

15 4) INSTALLING JEKYLL TOOLS WE WILL BE USING TODAY: ‣ Command Line/Terminal ‣ Text Editor ‣ Web Browser Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 16

Slide 16

16 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL GIT 1. Open Command Line 2. Install git from https://git-scm.com/downloads 3. Confirm installation by running: ‣ $ git -—version Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 17

Slide 17

17 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL GIT ▸ Configure git with your name and e-mail address. $ git config —global user.name “John Doe” $ git config —global user.email johndoe@example.com Use the same e-mail that is associated with your GitHub account. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 18

Slide 18

18 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL RUBY ▸ Install Ruby ▸ On Windows: ▸ Use RubyInstaller ▸ On Mac: ▸ By default Ruby may be installed depending on OS. If not: $ brew install ruby Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 19

Slide 19

19 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL RUBY ▸ Install Ruby and check that version is greater than 2.4.1 Ruby -v ▸ If not install the latest version of Ruby: rvm install ruby-2.5.1 ▸ If wrong version of Ruby is being used: rvm use —-default 2.5.1 Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 20

Slide 20

20 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL PROJECT ▸ On GitHub.com fork this repository https://github.com/ M0nica/dactl Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 21

Slide 21

21 4) INSTALLING JEKYLL INSTALLATION FEST - INSTALL PROJECT ▸ On command line: ▸ Git clone https://github.com/YOUR_USERNAME/dactl ▸ Note: GitHub may prompt you to login with your credentials. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 22

Slide 22

22 4) INSTALLING JEKYLL

  1. FORK MY REPOSITORY AT: HTTPS://GITHUB.COM/M0NICA/DACTL ▸ On GitHub.com fork this repository https://github.com/ M0nica/dactl ▸ On command line: ▸ Git clone https://github.com/YOUR_USERNAME/dactl may prompt you to login with your ▸ Note: GitHub 2. NAVIGATE TO THE REPOSITORY YOU credentials.JUST FORKED. TYPE ‘GIT CLONE’ IN YOUR TERMINAL FOLLOWED BY THIS URL. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 23

Slide 23

23 4) INSTALLING JEKYLL INSTALLATION FEST - CONFIRM INSTALLATION ▸ Install dependencies and then view Jekyll site with the following commands: $ $ $ $ gem install bundler cd dactl bundle install bundle exec jekyll serve Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 24

Slide 24

24 4) INSTALLING JEKYLL INSTALLATION FEST - CONFIRM INSTALLATION ▸ Visit this website to see local version of the site: ▸ http://127.0.0.1:4000/dactl/ Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 25

Slide 25

EDITING JEKYLL SITE

Slide 26

Slide 26

26 CREATE A BLOG WITH JEKYLL YAML _CONFIG.YML ‣ Let’s introduce our blog to the world wide web by giving it a title and description! ‣ We will need to edit the _config.yml file to accomplish this. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 27

Slide 27

27 CREATE A BLOG WITH JEKYLL YAML _CONFIG.YML ‣ Activity: Edit site url, title and description in the _config.YML file. ‣ Hint: server can be reset by typing “ctrl + C” in terminal followed by “bundle exec jekyll serve”. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 28

Slide 28

WRITE FIRST BLOG POST

Slide 29

Slide 29

29 CREATE A BLOG WITH JEKYLL WRITE FIRST BLOG POST ‣ Jekyll required file name format for blog posts: ‣ YEAR-MONTH-DAY-title.MARKUP ‣ E.g., 2018-05-04-code-land—is-awesome.md ‣ Learn more about excerpts here: https://m0nica.github.io/ dactl/posts/post-excerpts-lead-paragraphs Monica Powell • Codeland 2018 Source: Jekyll Documentation @waterproofheart • www.aboutmonica.com

Slide 30

Slide 30

30 CREATE A BLOG WITH JEKYLL YAML FRONT MATTER “Any file that contains a YAML* front matter block will be processed by Jekyll as a special file. The front matter must be the first thing in the file and must take the form of valid YAML set between triple-dashed lines.” (Source: Jekyll Documentation) Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 31

Slide 31

31 CREATE A BLOG WITH JEKYLL YAML FRONT MATTER ‣ Activity: create the front matter for a new post and view it on local server. ‣ Tip: Create a catchy headline to draw readers in! Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 32

Slide 32

32 CREATE A BLOG WITH JEKYLL MARKDOWN REVIEW ‣ https://markdown-it.github.io/ ‣ Activity: Write a short post in Markdown about something(s) you’ve learned or enjoyed at Codeland so far! Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 33

Slide 33

CREATE A BLOG WITH JEKYLL 33 MARKDOWN REVIEW Monica Powell • Codeland 2018 Source: Jekyll Documentation @waterproofheart • www.aboutmonica.com

Slide 34

Slide 34

34 CREATE A BLOG WITH JEKYLL YAML FRONT MATTER ‣ Activity edit post: ‣ Change photo overlay in front matter of our post from red to blue, green, purple or orange. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 35

Slide 35

35 CREATE A BLOG WITH JEKYLL PUBLISH CONTENT - GITHUB PAGES ‣ Activity: Publish our work on Github! ‣ Commit work to GitHub via the following commands: git git git git status add . commit -m “commit message” push Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 36

Slide 36

36 CREATE A BLOG WITH JEKYLL PUBLISH CONTENT - GITHUB PAGES ‣ After successfully committing to GitHub, go to your repository’s settings page: Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 37

Slide 37

37 CREATE A BLOG WITH JEKYLL PUBLISH CONTENT - GITHUB PAGES Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 38

Slide 38

38 CREATE A BLOG WITH JEKYLL PUBLISH CONTENT - GITHUB PAGES ‣ This message should appear after refreshing the page. You can click the link to view your blog on GitHub. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 39

Slide 39

39 CREATE A BLOG WITH JEKYLL ADDING CONTENT - CODE BLOCKS ‣ Activity: Add a block of code to your blog post {% highlight ruby %} def foo puts ‘foo’ end {% endhighlight %} Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 40

Slide 40

40 CREATE A BLOG WITH JEKYLL HIDING CONTENT - DRAFTS ‣ Activity: Create a draft blog post 1. Drafts are posts without date. 2. Should go in a _drafts folder (in project’s root directory) 3. Drafts should only appear when you run: ‣ bundle exec jekyll serve —-drafts Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 41

Slide 41

41 CREATE A BLOG WITH JEKYLL ADDING CONTENT - ABOUT PAGE ‣ Activity: Edit About page to better reflect YOU! Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 42

Slide 42

42 CREATE A BLOG WITH JEKYLL ADDING CONTENT - IMAGES ‣ Currently our about.md file is using our author photos which are defined in config.yml. about.md referencing image set in config.yml Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 43

Slide 43

43 CREATE A BLOG WITH JEKYLL ADDING CONTENT - IMAGES ‣ Update author photo by uploading an image of yourself or your favorite animal/character to the uploads folder. 1. In config file change line 38 and 39 to the name of your file: 38 photo : “uploads/me2.png” 2. Reset Server Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 44

Slide 44

CREATE A BLOG WITH JEKYLL ADDING PARTIAL - IMAGES Pictures are important when blogging. You should never use photos you do not have the rights to use. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 45

Slide 45

CREATE A BLOG WITH JEKYLL ADDING PARTIAL - IMAGES Below are stock photos that are free for re-use: ‣ https://www.flickr.com/photos/wocintechchat/ (require attribution to #WOCinTech) ‣ https://unsplash.com/ ‣ https://www.pexels.com/ Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 46

Slide 46

46 CREATE A BLOG WITH JEKYLL ADDING CONTENT - IMAGES 1. Find an image! 2. Add image to assets. 3. In YAML post hero: reference relative path “/assets/img/ filename.jpg” Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 47

Slide 47

CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ▸ “Posts with share buttons make content 7 times more shareable than content without them” ▸ Source: Salesforce Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 48

Slide 48

48 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ‣ Partial layouts can be found in the /_includes folder of our project. ‣ Partials = HTML templates with re-usable elements that are found on multiple pages such as as the header, footer, etc. ‣ Activity: Add social icons to all of our posts. Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 49

Slide 49

49 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ‣ We will be using Font Awesome’s free social icons. ‣ FA is referenced in the head of our head.html: Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 50

Slide 50

50 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS 1. Create a file named share_icons.html in the post folder within the _includes folder. 2. Add a link to the partial file we just created (code below) in our post layout in _layouts/ post.html —layout: default —- {% include post.html post=page %} <!— The following line links to the partial we created for our social-share-icons —> {% include post/share_icons.html %} {% if site.author.disqus %} {% include externals/disqus.html %} {% endif %} {% include post/related.html %} Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 51

Slide 51

51 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ‣ Add HTML for social icons to share_icons.html <div class=”share-page”> <h3>Share “{{ page.title }}”:</h3>

<ul class=”icons”> <li><a href=”https://twitter.com/intent/tweet?text={{ page.title }}&url={{ site.url }}{{ page.url }} &via={{ site.author.twitter }}&related={{ site.author.twitter }}” rel=”nofollow” target=”_blank” title=”Share on Twitter”><i class=”fab fa-twitter”></i></a></li> <li><a href=”https://facebook.com/sharer.php?u={{ site.url }}{{ page.url }}” rel=”nofollow” target=”_blank” title=”Share on Facebook”><i class=”fab fa-facebook-f”>&nbsp;</i></a></li> <li><a href=”https://www.linkedin.com/shareArticle?mini=true&url={{ site.url }}{{ site.baseurl }} {{ page.url }}&title={{ page.title }}&summary={{ page.description }}&source={{ site.title }}” onclick=”window.open(this.href, ‘pop-up’, ‘left=20,top=20,width=500,height=500,toolbar=1,resizable=0’); return false;” title=”Share on LinkedIn”><i class=”fab fa-linkedin-in”></i></a></li> </ul> </div> Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 52

Slide 52

52 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ‣ Add styling for social icons in the _icons.scss file in our _sass folder. // /* Style all font awesome icons */ .fab { padding: 20px; width: 100px; text-align: center; text-decoration: none; color: white; } ul.icons { -webkit-padding-start: 0px; } ul.icons li { display: inline-block; margin: 10px; } Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 53

Slide 53

53 CREATE A BLOG WITH JEKYLL ADDING PARTIAL - SOCIAL ICONS ‣ Add background-color for social icons in the _icons.scss file in our _sass folder. According to the brands colors. // /* Style all font awesome icons */ i.fab.fa-twitter { background-color: #1da1f2; } i.fab.fa-linkedin-in { background-color: #0077b5; } i.fab.fa-facebook-f { background-color: #3b5998; } Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 54

Slide 54

54 CREATE A BLOG WITH JEKYLL EDIT CSS - UPDATE HEADER COLOR ‣ Edit css in _SASS/_variables.scss Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 55

Slide 55

55 CREATE A BLOG WITH JEKYLL EDIT CSS - UPDATE HEADER COLOR ‣ Change the hex color in line 24 from $link-color: #8BC34A; to another hex color. ‣ Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 56

Slide 56

56 CREATE A BLOG WITH JEKYLL CODING FREESTYLE ‣ Delete stock posts ‣ Upload new site icon! ‣ Change color scheme ‣ Customize 404 Page ‣ Add a new posts or pages ‣ Update variables in config.yml Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 57

Slide 57

SHOW EVERYONE WHAT YOUR BLOG LOOKS LIKE SHOW AND TELL

Slide 58

Slide 58

CREATE A BLOG WITH JEKYLL NEXT STEPS ▸ Resources/Ideas of things to do with Jekyll ▸ https://jekyllrb.com/docs/resources/ ▸ Read about how to get published in the largest technical publication on Medium: https://medium.freecodecamp.org/how-to-get-published-in-the-freecodecampmedium-publication-9b342a22400e ▸ Check out other static site generators: ▸ Gatsby (React-based) ▸ Hugo (Go-based) Monica Powell • Codeland 2018 @waterproofheart • www.aboutmonica.com

Slide 59

Slide 59

🎉 THANK YOU! QUESTIONS? Feel free to e-mail me at: Monica@AboutMonica.com