Developing and Maintaining Websites with Eleventy
This website is based on the static site generator Eleventy, the template language Liquid, and the markup language Markdown.
Contents
Working on the Website
Before making changes to the website’s layout and content, start Eleventy and the development server:
npx @11ty/eleventy --ignore-initial --incremental --serveOption
--ignore-initialprevents the initial build of the whole website.Option
--incrementalbuilds only pages that need to be rebuilt because of changes to the page or the layout. Incremental builds require declaration of collections used by certain layouts or pages.
Publishing the Website
When the changes (e. g., adding new pages, editing pages, modifying the layout) are done, call a shell script publish.sh to upload the changed pages to the web server using 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 will only upload files that do not yet exist on the web server or are newer than the files on the web server. It can be installed on Linux Mint:
sudo apt install lftpSetting File Permissions
The correct file permissions are important for this approach to work, as LFTP will retain the permissions of the transferred files. Read permissions have to be set for other so the uploaded files can be accessed via HTTP. The bash script correct-permissions.sh below can be used to correct directory and file permissions in the content directory:
#!/usr/bin/env bash
find content -type d -exec chmod 755 {} +
find content -type f -exec chmod 644 {} +