Developing and Maintaining Websites with Eleventy

Information on developing, editing, and publishing a website using the static site generator Eleventy.

Contents

Introduction

The website firstan.org is based on the static site generator Eleventy, the template language Liquid, and the markup language Markdown. This document provides instructions for developing, editing, and publishing websites using Eleventy.

Working on the Website

Before making changes to the website’s layout or content, start Eleventy and the development server:

npx @11ty/eleventy --ignore-initial --incremental --serve

Publishing the Website

Once the changes—such as adding or editing pages, or modifying the layout—are complete, run the publish.sh shell script to upload the updated pages to the web server via FTP:

#!/usr/bin/env bash

USER='<user name>'
PASSWORD='<password>'
HOST='example.org'
LOCAL_DIR="$(pwd)/_site/"   # Trailing slash prevents creating dir on server.
REMOTE_DIR='/'
NUM_PARALLEL_CONNS=8

# LFTP's `mirror` command supports an option `--delete` to delete files that
# are not present in the source.  However, this option should only be used if
# the project has a dedicated directory on the server.
echo "Starting upload at $(date)."
lftp -u "$USER","$PASSWORD" $HOST << EOF
#set ftp:ssl-allow true
#set ftp:ssl-force true
#set ftp:ssl-protect-data true
#set ssl:verify-certificate no
mirror --parallel=$NUM_PARALLEL_CONNS --verbose -R "$LOCAL_DIR" "$REMOTE_DIR";
exit
EOF
echo "Upload finished at $(date)."

The FTP client LFTP only uploads files that do not yet exist on the web server or are newer than the remote versions. It can be installed on Linux Mint:

sudo apt install lftp

Setting File Permissions

Correct file permissions are essential for this approach to work, since LFTP retains the permissions of transferred files. Enabling read permissions for others ensures the uploaded files can be accessed via HTTP. To correct directory and file permissions in the content directory, use the correct-permissions.sh bash script below:

#!/usr/bin/env bash

find content -type d -exec chmod 755 {} +
find content -type f -exec chmod 644 {} +