Cottage Labs website, powered by Pelican
Create a virtualenv, if you like.
Install pelican
with
pip install pelican pelican-yaml-metadata
Generate content from the project root with the command
pelican content
We commit the resulting HTML from the build (under output/
) into the repo so it can be served immediately from the repo on the server.
Run the server from the project root
pelican --listen
For development you can use auto-reload mode so you can see changes immediately in browser:
pelican --autoreload --listen
Install sass with e.g.
sudo apt install ruby-sass
Generate styles from themes/simple/static/scss
scss main.scss main.css
.md
to the /content/projects
folderproject
)/that-page
url), template.html
template in /themes/simple/static/templates
nav.html
templates
can be found in src/themes/simple/static/templates
content
can be found in src/content/pages
content/images
and can be referenced by {static}/images
themes/simple/static/images
and can be referenced by {{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/
(from the template) and url("../images/[...]");
(from the stylesheet)output
is autogenerated/
/about
/data-lifecycle
/project-lifecycle
/data-visualisation
/data-repositories
/bespoke-development
/open-access-infrastructure
/{project-name}
project.html
projects/{project-name}.md
themes/simple/static/images/projects
themes/simple/static/screenshots
/projects
/projects/{technology}
tags.html
tag.html
browser.html
src/themes/simple/templates/partials/_tags.html
for slugs and tags' namesThis is managed using git hooks. You'll need the server in your .ssh/config
file,
and run the following from your local checked-out repo to add the remote:
git remote add next cloo@sauron:next.cottagelabs.com.git
You can only deploy the master branch. To do so, run the following command:
git push next master
i.e. you are pushing master to the remote repo on machine sauron
. This will run the hooks, and
restart nginx
for you to pick up the changes.
Requires a bare git repo on the host, e.g. called next.cottagelabs.com.git
. This is created
with git init --bare next.cottagelabs.com.git
in the home directory.
Create the working tree directory where nginx will serve the files from and fix the permissions:
sudo mkdir /var/www/next.cottagelabs.com
sudo chown www-data:www-data /var/www/next.cottagelabs.com
sudo chmod -R 775 /var/www
sudo usermod -a -G www-data cloo
The post receive hook then needs to be created on the host, by copying
deploy/hooks/post-receive
to ~/next.cottagelabs.com.git/hooks/post-receive
and
chmod +x hooks/post-receive
on the host. This will allow the script to run on
deploy and copy the code to the correct work tree.
Afterwards, replace the copied hook with a symlink to the checked out hook (so you can update the hooks):
ln -sf /var/www/next.cottagelabs.com/deploy/hooks/post-receive hooks/post-receive
chmod +x hooks/post-receive
Set up server as above, but with production
instead of next
, and a host set up for cottagelabs.com
:
git remote add production cloo@cl-docker:cottagelabs.com.git
git push production master
Also, use the -production
hook which is hardcoded for cottagelabs.com
, along with its corresponding nginx
config.
The nginx config expects an SSL certificate - this should be created via LetsEncrypt / certbot.
To use the nginx config, symlink it within /etc/nginx/sites-available
and add a symlink to that one inside /etc/nginx/sites-enabled
.
e.g.
sudo ln -s /var/www/next.cottagelabs.com/deploy/nginx/next.cottagelabs.com /etc/nginx/sites-available/next.cottagelabs.com