67
Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds!

Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Angular 2 and HexoStatic Meets Dynamic For the Best of Both Worlds!

Page 2: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Who am I?

Jeff Ammons

Microsoft MVP

Pluralsight Author

CEO/Chief Instructor at Code Career

Academy

25 Years Professional Experience in Software

Page 3: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

Page 4: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

Page 5: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Page 6: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Markdown

Page 7: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Markdown

Rendered HTML Output

Page 8: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

Page 9: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

Page 10: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

• Deploy with Git

Page 11: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

What is a Static Website Generator?

• Store content as text files of Markdown and YAML

• Run processor locally to convert to HTML files

• Version with Git

• Deploy with Git

• Serve plain files via any web server

Page 12: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Why Would I Want One?

•Speed

•Scalability

•Reliability

•Lower Attack Surface

•Version Control

•Tools

•Zero Lock-in

Page 13: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

When does it make sense?

• Primarily content site

• Blog

• “Brochure-ware” Site

Page 14: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

When does it NOT make sense?

• Everything else…

• It’s not called a “General Purpose Site Generator”…

Page 15: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Writing

Page 16: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Writing

Page 17: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Writing

Page 18: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Reading

Page 19: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Reading

Page 20: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Reading

Page 21: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Reading

Page 22: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Traditional CMS: Reading

Page 23: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Writing

Page 24: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Writing

Page 25: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Writing

Page 26: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Generating

Page 27: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Generating

Page 28: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Generating

Page 29: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Generating

Page 30: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Generating

Page 31: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Publishing

Page 32: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Publishing

Page 33: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Publishing

Page 34: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Reading

Page 35: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Reading

Page 36: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Reading

Page 37: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Scaling

Page 38: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Scaling

Page 39: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Static Site Generator: Scaling

Page 40: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

YAML

Markdown

CommonPost Format

Page 41: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

YAML

YAML Ain't Markup Language

YAML is a human friendly data serialization

standard for all programming languages.

Source: yaml.org

Page 42: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Markdown

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

Source: http://daringfireball.net/projects/markdown/

Page 43: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

Page 44: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Page 45: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Markdown

Page 46: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Sample Post Format

YAML

Markdown

Rendered HTML Output

Page 47: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Hexo Prerequisites

• Node.js

• Npm

• Git

• Text editor

Page 48: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Which Text Editor Should I Use?

• Sublime Text

• Visual Studio Code

• Atom

• Notepad++

• Vim

• Emacs

• [Insert any other editor you like here]

Page 49: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Hexo

• Super simple

• Fast

• Easy to work with

Page 50: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Super Easy Install

npm install hexo-cli -g

Page 51: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Create a New Blog

hexo init

npm install

Page 52: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Create a New post

hexo new “My New Post”

hexo new post “My New Post”

Page 53: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Test Blog Locally

hexo server

Page 54: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Generate Blog for Publishing

hexo generate

Page 55: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Just Enough Git

git init

git add .

git commit –m “My commit message”

git push origin master

Page 56: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Where Can I Deploy my Blog?

• GitHub Pages

• Azure Web App

• Windows Server

• Linux Server

• Raspberry Pi

• … Any web server

Page 57: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

For Full Instructions…

• Check out my Pluralsight course!

• Build a Better Blog with a Static Site Generator

• https://www.pluralsight.com/courses/static-site-generator-build-better-blog

Page 58: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

How About the Dynamic Bits??

• Hexo Widgets

• UI Elements supported by many themes

• Angular 2 Components are a nice fit

• React is also great

• jQuery and Vanilla JS also!

• Keep the static bits static and the dynamic bits dynamic!

Page 59: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author
Page 60: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Dynamic

Widget

Page 61: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Seasoning

• Dynamic widgets should be the salt and pepper on static content sites

• Don’t over do it!

• Otherwise it was never really a static content site

Page 62: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Where can I get dynamic content?

• REST APIs

• Public APIs

• Your own API sites

• Pre-gen JSON files

• Pre-gen HTML fragment

Page 63: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Example Widget/Component Sources

Meetup.com

Page 64: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Example Widget/Component Sources

MySite.com

Node.js

Ruby on Rails

ASP.NET

Page 65: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Example Widget/Component Sources

MySite.com

Node.js

Ruby on Rails

ASP.NET

OAUTH

Secure

the API

not the site

Page 66: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Resources

• https://hexo.io/

• https://www.staticgen.com/

• https://www.pluralsight.com/courses/static-site-generator-build-better-blog

• http://ammonsonline.com/top-5-reasons-to-blog-with-a-static-file-generator/

Page 67: Angular 2 and Hexo - ccawebfiles.blob.core.windows.net · Angular 2 and Hexo Static Meets Dynamic For the Best of Both Worlds! Who am I? Jeff Ammons Microsoft MVP Pluralsight Author

Contact Info

• https://www.pluralsight.com/authors/jeff-ammons

• Company: https://codecareeracademy.com

• Email: [email protected]

• Twitter: jeffa00

• Linked-In: jeffammons

• Blog: http://jeffa.tech

• User Group: http://ggmug.com