nikola, a static blog & site generator python meetup 19 feb2014

17
Areski Belaid <[email protected]> 19th February 2014 Nikola a static Blog & Site generator slideshare.net/areski/

Upload: areski-belaid

Post on 27-Jun-2015

2.560 views

Category:

Technology


0 download

DESCRIPTION

Python static blog & site generator

TRANSCRIPT

Page 1: Nikola, a static blog & site generator   python meetup 19 feb2014

Areski Belaid<[email protected]>

19th February 2014

Nikola a static Blog & Site

generator

slideshare.net/areski/

Page 2: Nikola, a static blog & site generator   python meetup 19 feb2014

Who am I?- Areski!- CTO at Star2Billing- VoIP guy, have worked with Python for many years- Love the web, day2day work with Django & Flask (Build a lot of Telefony products using Django/Flask)

- I might need a haircut…

Page 3: Nikola, a static blog & site generator   python meetup 19 feb2014

WAT! This is not a Web-Framework...Sorry guys! I know this talk doesn’t fit with

tonight’s topic?

Page 4: Nikola, a static blog & site generator   python meetup 19 feb2014

Pybcn.org- 2 months ago we built pybcn.org for our Python Group

- Hosted on Github Pages

Goals:

- a simple website to provide information about the events in a more friendly fashion (use bootstrap3)

- No cost / Self maintained

- Still in discussion of what will happen on pybcn.org...

Page 5: Nikola, a static blog & site generator   python meetup 19 feb2014

Nikola is a static website and blog generator

It allows you to build a website/blog by simply writing text.

You will write your Post/Page content in a text file and Nikola will generate the HTML pages, the website structure, URLs, links, menu, etc…

“It will leverage all the heavy work of creating websites!”

It’s very easy use… Don’t believe me!?

Page 6: Nikola, a static blog & site generator   python meetup 19 feb2014

Why statichttp://getnikola.com/handbook.html#why-static

SecurityDynamic sites are prone to experiencing security issues.

ObsolescenceIf you create a site (ie using a CMS), what happens when CMS releases a new version?

Cost and PerformanceOn dynamic sites, every time a reader requests a page, a whole lot of database queries are made.

Time & MaintenanceHosting on Github page is extremely fast, no need to configure Apache/Nginx. Once it's there it will stay there.

Page 7: Nikola, a static blog & site generator   python meetup 19 feb2014

Nikola featuresMost remarkable features:

- Blogs, with tags, RSS feeds, archives, comments, etc.

- A lot of themes: https://github.com/getnikola/nikola-themes

- Flexible, extensible via plugins (https://github.com/getnikola/plugins)

- reStructuredText or Markdown as input language (also Wiki, BBCode, Textile, and HTML)

- Easy image galleries (just drop files into a folder!)

- Preview web server examples

- Live re-rendering while you edit

….

Page 8: Nikola, a static blog & site generator   python meetup 19 feb2014

Markdown & RestructuredtextPlain text formatting syntax designed so that it can be converted to HTML

Page 9: Nikola, a static blog & site generator   python meetup 19 feb2014

Install Nikola in 3 steps1) create a virtualenv :

$ mkvirtualenv myownpybcn-website

2) install nikola:$ pip install Nikola

3) install python-requests & livereload:$ pip install requests==2.2.1$ pip install livereload==2.1.0

Page 10: Nikola, a static blog & site generator   python meetup 19 feb2014

Let's create a demo website1) Let’s create a demo site with fake data

$ nikola init --demo myownpybcnThis created directory myownpybcn, if you don't want the demo files remove --demo

`Explorons` what has been created:- files: directory contains static assets- galleries: reveal the photo gallery feature of Nikola- posts: keep all your post files in a chosen markup language- stories: contains all the "static" pages (non-post pages)

and finally `conf.py`, the config file for your site

Page 11: Nikola, a static blog & site generator   python meetup 19 feb2014

Let’s create a post$ nikola new_post

Creating New Post

-----------------

Enter title: my new post

Scanning posts....done!

[2014-02-13T16:17:46Z] NOTICE: new_post: Your post's text is at: posts/my-new-post.rst

then edit posts/my-new-post.rst and write more content

Page 12: Nikola, a static blog & site generator   python meetup 19 feb2014

Let's build itHow to build it (even my mum can do it):

$ nikola build

Some magic happens here… read your conf.py files, based on your templates, assests, custom css, plugins used, etc… it will produce HTML pages to create a full functional Website

All the static files are stored in the folder output, you can open the output/index.html

Yeah I know, it’s too easy :/

Page 13: Nikola, a static blog & site generator   python meetup 19 feb2014
Page 14: Nikola, a static blog & site generator   python meetup 19 feb2014

Serve it on a plate

Nikola can serve all the static files from `output` directory locally:$ nikola serve

Point your browser to the ip/port indicated - http://127.0.0.1:8000/'CRTL-C' to terminate

We installed `livereload` earlier this will help to reload our website automatically every time we edit our code.

$ nikola auto

Page 15: Nikola, a static blog & site generator   python meetup 19 feb2014

Configure your conf.py

The configuration file is called conf.py and can be used to customize a lot of what Nikola does

# Data about this siteBLOG_TITLE = "Demo Site"SITE_URL = "http://getnikola.com"BLOG_EMAIL = "[email protected]"BLOG_DESCRIPTION = "This is a demo site for Nikola."

but also:- Configure your Menu, multi-language, google-analytic, comment(disqus), RSS feed, configure the template, and much more

Page 16: Nikola, a static blog & site generator   python meetup 19 feb2014

Conclusion

- Static website fits many cases

- Nikola is a great tool and it’s Python based

- Very fast to use: in a matter of minutes you can create functional Websites

- Nikola has a lot of plugins & short codebase

- Many templates, support bootstrap / bootstrap3

Time to get started : http://getnikola.com/