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
- Add the content file
.md
to the/content/projects
folder - add required metadata to the header: title, tags (this will allow the project to be found by the project browser), template (
project
)
- Add the content file '.md' to the '/content/pages' folder
- add required metadata to the header: title ("That Page" will translate to
/that-page
url), template
- Create
.html
template in/themes/simple/static/templates
- Create link in
nav.html
templates
can be found insrc/themes/simple/static/templates
content
can be found insrc/content/pages
- images referenced from the content should be added to
content/images
and can be referenced by{static}/images
- images referenced from the theme (templates and scss files) should be added to
themes/simple/static/images
and can be referenced by{{ SITEURL }}/{{ THEME_STATIC_DIR }}/images/
(from the template) andurl("../images/[...]");
(from the stylesheet) - folder
output
is autogenerated
- index.html
- to do: how to add content in md file to index page?
- about.html
- partners.html
- registration.html
- about.md
- partners.md
- registration.md
/data-lifecycle
/project-lifecycle
- lifecycles.html
- datalifecycle.md
- projectlifecycle.md
/data-visualisation
/data-repositories
/bespoke-development
/open-access-infrastructure
- expertise.html
- datavisualisation.md
- datarepositories.md
- bespokedevelopment.md
- oainfrastructure.md
/{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
This 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