Slide 1

Slide 1 text

Creating Static Sites with Pelican ♡ Jaime Arias Inria Grenoble Rhône-Alpes November 29, 2016

Slide 2

Slide 2 text

Outline 1. Installation 2. New Project 3. New Page 4. Generation of the Site 5. Themes 6. Plugins 7. Advanced Configuration 8. Publishing 9. Modifications Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 1/19 1/19

Slide 3

Slide 3 text

1. Installation

Slide 4

Slide 4 text

Installation • “Pelican” is an anagram of calepin ¿? • Language → Python ♡ • Some features: ◦ Articles → blog posts ◦ Pages → About, Contact, etc. ◦ Plugins → Disqus, Bibtex, etc. ◦ Theming support → Jinja2 templates ◦ Code syntax highlighting ◦ Integration with external tools → Google, Twitter, etc. • Available formats: ◦ reStructuredText → http://docutils.sourceforge.net/rst.html ◦ Markdown → http://assemble.io/docs/Cheatsheet-Markdown.html Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 2/19 2/19

Slide 5

Slide 5 text

Installation • Repository → https://github.com/getpelican/pelican • Documentation → http://docs.getpelican.com/ •1 pip install --user pelican markdown typogrify Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 3/19 3/19

Slide 6

Slide 6 text

2. New Project

Slide 7

Slide 7 text

New Project 1. Create a new project 1 mkdir -p ~/mysite 2 cd ~/mysite 3 pelican-quickstart 2. When asked for your URL prefix, enter your domain name as indicated. 1 > Do you want to specify a URL prefix? e.g., http://example.com (Y/n) Y 2 3 > What is your URL prefix? (see above example; no trailing slash) https://himito-test.github.io → 4 5 > Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) Y → 6 7 > Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) Y → 8 9 > Do you want to upload your website using GitHub Pages? (y/N) y 10 11 > Is this your personal page (username.github.io)? (y/N) y Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 4/19 4/19

Slide 8

Slide 8 text

3. New Page

Slide 9

Slide 9 text

New Page Trick If you create a folder named pages inside the content folder, all the files in it will be used to generate static pages, such as About or Contact pages. 1 mkdir -p content/blog 2 mkdir -p content/pages 3 echo "Title: About" >> content/pages/about.md Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 5/19 5/19

Slide 10

Slide 10 text

New Page 1 mysite/ 2 |-- content 3 | |-- blog 4 | |-- pages/ 5 | |-- about.md 6 |-- pelican.conf.py 7 |-- ... Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 6/19 6/19

Slide 11

Slide 11 text

4. Generation of the Site

Slide 12

Slide 12 text

Generation of the Site • From your site directory, run the pelican command to generate your site: 1 cd ~/mysite 2 pelican content • Preview your site by navigating to http://localhost:8000/ in your browser. 1 cd ~/mysite 2 ./develop_server.sh start Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 7/19 7/19

Slide 13

Slide 13 text

Generation of the Site Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 8/19 8/19

Slide 14

Slide 14 text

5. Themes

Slide 15

Slide 15 text

Themes • Repository → https://github.com/getpelican/pelican-themes • Live demos → http://www.pelicanthemes.com/ • Installation: 1. Create a directory to save the themes 1 cd ~/mysite 2 mkdir themes 2. Select a theme and install it 1 cd ~/mysite/themes 2 git clone https://github.com/fle/pelican-sober.git 3. Update pelicanconf.py 1 # Specify name of a theme installed via the pelican-themes tool 2 THEME = 'themes/pelican-sober' 4. Read the documentation of the theme to know how to configure it Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 9/19 9/19

Slide 16

Slide 16 text

Themes Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 10/19 10/19

Slide 17

Slide 17 text

6. Plugins

Slide 18

Slide 18 text

Plugins • Repository → https://github.com/getpelican/pelican-plugins • Installation: 1. Create a directory to save the plugins 1 cd ~/mysite 2 mkdir plugins 2. Select a plugin and install it 1 cd ~/mysite/plugins 2 git clone https://github.com/cmacmackin/pelican-cite.git 3. Update pelicanconf.py 1 PLUGIN_PATHS = ['plugins'] 2 PLUGINS = ['pelican-cite'] 4. Read the documentation of the plugin to know its dependencies and how to configure it Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 11/19 11/19

Slide 19

Slide 19 text

Plugins Configuration of pelican-cite • Installation of dependencies 1 pip install pybtex • Bibtex file 1 cd ~/mysite 2 mkdir -p content/files 3 cp {$MYBIBLIO_PATH}/mybiblio.bib ~/mysite/content/files • Updating pelicanconf.py 1 echo PUBLICATIONS_SRC = \'content/files/mybiblio.bib\' >> ~/mysite/pelicanconf.py → • Using the plugin in about.md 1 Hi my name is Jaime, you can find the results of my thesis in [@Arias:Journal_UPPAAL] → Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 12/19 12/19

Slide 20

Slide 20 text

Plugins Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 13/19 13/19

Slide 21

Slide 21 text

7. Advanced Configuration

Slide 22

Slide 22 text

Advanced Configuration My current configuration 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- # 3 from __future__ import unicode_literals 4 5 AUTHOR = u'Jaime Arias' 6 SITENAME = u"Himito's Blog" 7 SITEURL = '' 8 9 PATH = 'content' 10 TIMEZONE = 'Europe/Paris' 11 DEFAULT_LANG = u'en' 12 13 # Blogroll 14 LINKS = (('Pelican', 'http://getpelican.com/'), 15 ('You can modify those links in your config file', '#'),) 16 17 # Social widget 18 SOCIAL = (('You can add links in your config file', '#'), 19 ('Another social link', '#'),) 20 21 DEFAULT_PAGINATION = 10 22 23 # Theme 24 THEME = 'themes/pelican-sober' 25 26 # Plugins 27 PLUGIN_PATHS = ['plugins'] 28 PLUGINS = ['pelican-cite'] 29 30 # Configuration of pelican-cite 31 PUBLICATIONS_SRC = 'content/files/mybiblio.bib' Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 14/19 14/19

Slide 23

Slide 23 text

Advanced Configuration How can I override the generated URL of a specific page or article? • The following Markdown example could be stored in content/pages/home.md: 1 Title: Welcome to My Site 2 URL: 3 save_as: index.html 4 5 Thank you for visiting. Welcome! Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 15/19 15/19

Slide 24

Slide 24 text

8. Publishing

Slide 25

Slide 25 text

Publishing 1. Install ghp-import 1 pip install ghp-import 2. Stop the server 1 cd ~/mysite 2 ./develop_server.sh stop Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 16/19 16/19

Slide 26

Slide 26 text

Publishing 1. Create a Github account → https://github.com 2. Create a new repository {github_username}.github.io 3. Add the site to the repository 1 cd ~/mysite 2 git init 3 git remote add origin https://github.com/himito-test/himito-test.github.io.git 4 git checkout -b ghp-pages 5 echo output >> .gitignore 6 echo *.pyc >> .gitignore 7 git add -A 8 git commit -m "my first commit" 9 git push origin ghp-pages 4. Deploy your site 1 make github Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 17/19 17/19

Slide 27

Slide 27 text

Publishing GO!! https://himito-test.github.io Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 18/19 18/19

Slide 28

Slide 28 text

9. Modifications

Slide 29

Slide 29 text

Modifications 1. Clone the repository 1 git clone https://github.com/himito-test/himito-test.github.io.git ~/mysite 2. Change to the branch with the sources 1 cd ~/mysite 2 git checkout ghp-pages 3. {Insert here the modifications …} 4. Update the Github repository 1 git add -A 2 git commit "some modifications ..." 3 git push origin ghp-pages 5. Deploy your site 1 make github 6. Check your site updated on Internet! Jaime Arias, Inria Grenoble Rhône-Alpes (2016) Creating Static Sites with Pelican ♡ 19/19 19/19

Slide 30

Slide 30 text

Thank you for your attention!

Slide 31

Slide 31 text

Creating Static Sites with Pelican ♡ Jaime Arias Inria Grenoble Rhône-Alpes November 29, 2016