Site Tools


informatique:web:pelican

This is an old revision of the document!


Pelican

Notes personnelles, je ne sais à peu près pas ce que je fais.

Notes d'installation du générateur de sites statiques Pelican. On me l'a conseillé parce que Python, parce que simple pour les idiots qui n'ont pas envie de se prendre le chou avec Hugo ou Jekyll.

Notes suite à une installation pour test sur un conteneur Debian 12 sous Proxmox.

Installation

On installe pip, Python3 était déjà installé sur mon conteneur Debian :

apt install python3-pip -y

Définir une environnement virtuel Python

Sous Linux

mkdir undossier
python3 -m venv ~/undossier
source undossier/bin/activate

Sous Windows

python -m venv undossier
.\undossier\Scripts\activate

Comme je suis une feignasse, j'ai fait un script PowerShell pour ne pas me faire chier sous Windows :

venv.ps1
$path_global = "H:\Dev"
$path_venv = "Python\venv"
$py_activate = "Scripts\activate.ps1"
Set-Location -Path $path_global
powershell -noexit ".\$path_venv\$py_activate ; cd Pelican-test"

Et je le lance avec un batch (oui) en utilisant Windows Terminal :

start.bat
@ECHO OFF
SET folder="H:\Dev"
wt PowerShell -c %folder%\venv.ps1

Installer Pelican

On installe Pelican :

pip install "pelican[markdown]"

Créer un premier site

On créé un dossier et on lance l'assistant de Pelican :

mkdir monsupersite
cd monsupersite
pelican-quickstart

On répond aux questions de l'assistant :

pelican-quickstart 
Welcome to pelican-quickstart v4.10.1.

This script will help you create a new Pelican-based website.

Please answer the following questions so this script can generate the files
needed by Pelican.

    
> Where do you want to create your new web site? [.] 
> What will be the title of this web site? Erreur503
> Who will be the author of this web site? Yahiko
> What will be the default language of this web site? [en] fr
> Do you want to specify a URL prefix? e.g., https://example.com   (Y/n) Y
> What is your URL prefix? (see above example; no trailing slash) https://blog.erreur503.xyz
> Do you want to enable article pagination? (Y/n) Y
> How many articles per page do you want? [10] 5
> What is your time zone? [Europe/Rome] Europe/Paris
> Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n) Y
> Do you want to upload your website using FTP? (y/N) N
> Do you want to upload your website using SSH? (y/N) y
> What is the hostname of your SSH server? [localhost] 
> What is the port of your SSH server? [22] 
> What is your username on that server? [root] 
> Where do you want to put your web site on that server? [/var/www] 
> Do you want to upload your website using Dropbox? (y/N) 
> Do you want to upload your website using S3? (y/N) 
> Do you want to upload your website using Rackspace Cloud Files? (y/N) 
> Do you want to upload your website using GitHub Pages? (y/N) 
Done. Your new project is available at /root/pelican

Créer une page

Dans monsupersite/content on créé un fichier md.

article.md
Title: Mon super article
Date: 2024/11/13 21:43
Category: 3615 Ma vie
Tags: pelican, ma vie, test, osef
Slug: mon-super-article
Authors: Lapinours
 
# Titre 1
## Titre 2
Wow, un **super** article sur `Pelican`.
 
Tellement _beau_ et **_frais_**.

Script PowerShell

Pour générer un peu plus rapidement les articles lors de mes tests, j'ai fait rapidement ce script PowerShell :

article.ps1
$file_ext = "md"
$file_name = Read-Host -Prompt "Nom du fichier"
$article_title = Read-Host -Prompt "Titre de l'article"
$article_date = Get-Date -Format "yyyy-MM-dd HH:mm"
$article_category = Read-Host -Prompt "Catégorie de l'article"
$article_tags = Read-Host -Prompt "Tags, séparés par des virgules"
$article_slug = $file_name
$article_authors = "Lapinours"
 
New-Item $file_name'.'$file_ext
Set-Content $file_name'.'$file_ext "Title: $article_title
Date: $article_date
Category: $article_category
Tags: $article_tags
Slug: $article_slug
Authors: $article_authors"

Publier

pelican /chemin/monsupersite/content -s /chemin/monsupersite/pelicanconf.py

Pour mon environnement de test j'ai installé Apache comme un sagouin. J'ai copié le contenu du dossier output de Pelican vers /var/www/html/output :

cp -r /chemin/supersite/output /var/www/html

La commande make html permet aussi d'exporter le site en HTML en utilisant pelicanconfig.py.

make publish va publier le site selon le fichier de conf make publish

Installer un thème

Pas terminé, je suis propablement teubé, ou j'ai encore lu la doc trop en diagonale.

De base Pelican produit des pages HTML très simples. C'est bien mais ce n'est pas très très pratique. On va installer les thèmes depuis le dépôt git. La page Pelican Theme propose d'un aperçu d'une partie des thèmes. Globalement tout est un petit peu pas très joli 😅.

On va suivre bêtement la doc et cloner le repo git des thèmes Pelican :

git clone --recursive https://github.com/getpelican/pelican-themes ~/pelican-themes

On va éditer le fichier de conf du site :

pelicanconf.py
THEME = "/home/jeanjean/pelican-themes/nomdutheme"
informatique/web/pelican.1731868581.txt.gz · Last modified: 2024/11/17 18:36 by yahiko