Deploy pelican to cloudflare
Marcelino Veloso III, , last modified on 19 May 2023Python version
The pyproject.toml
should contain the Python version used by Pelican. This will be communicated to Cloudflare on deployment.
python = "^3.10" # note version
pelican = "^4.8"
markdown = "^3.4.3"
The Cloudflare docs default to 3.10.5 under the beta build system version.
Adjustment is possible but the disadvantage is that Cloudflare Pages will have to download and install the adjusted Python version every single deployment. 3.10.5 seems good enough. I employ a .python-version
file with a single line (can also specify the PYTHON_VERSION
env variable in the dashboard) to explicitly provide:
3.10.5
requirements.txt
Ensure updated requirements.txt
via:
poetry export -f requirements.txt \
--without-hashes \
--output requirements.txt
Without the requirements.txt
, using just poetry fails:
Installing project dependencies: poetry install
... /bin/sh: 1: poetry: not found
publishconf.py
- Add
SITEURL
- Set
FEED_DOMAIN = SITEURL
- Finalize
DIRECT_TEMPLATES
Setup Custom Domain
- Add nameservers re:
sampledomain.com
- Add
www
record forsampledomain.com
- Add page rule to permanently redirect
www.sampledomain.com
tohttps://sampledomain.com
Configure
Link repo to Cloudflare modifying:
Configuration option | Value |
---|---|
Build command |
pelican content |
To:
Configuration option | Value |
---|---|
Build command |
pelican content -s publishconf.py |