Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creating Static Sites with Pelican

Creating Static Sites with Pelican

Jaime Arias Almeida

November 29, 2016
Tweet

More Decks by Jaime Arias Almeida

Other Decks in Technology

Transcript

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. Generation of the Site Jaime Arias, Inria Grenoble Rhône-Alpes (2016)

    Creating Static Sites with Pelican ♡ 8/19 8/19
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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