Quick Install

One command is all you need to start a new website.

After Dark includes a portable installation script for quick set-up:

themes/after-dark/bin/install
Expand to view script
  1#!/bin/sh
  2
  3validate_hugo () {
  4   # Exit with error if hugo is not installed
  5   if ! hash hugo 2>/dev/null ; then
  6     echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
  7   fi
  8
  9   # Exit with error if not minimum required hugo version
 10   re="v(0\d*\.([4-9][4-9]|[5-9])|[1-9]).*"
 11   if ! hugo version | grep -qE "$re" ; then
 12      echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
 13   fi
 14}
 15
 16create_site_dir () {
 17   SITE_DIR="flying-toasters"
 18   if [ "$1" != "" ] ; then
 19      SITE_DIR="$1"
 20   fi
 21
 22   SITE_DIR_ABS="$PWD/$SITE_DIR"
 23   mkdir -p "$SITE_DIR"
 24}
 25
 26create_site () {
 27   echo "Creating a new Hugo site ..."
 28   hugo new site "$SITE_DIR" 1>/dev/null
 29   cd "$SITE_DIR" || exit 1
 30}
 31
 32download_theme () {
 33   echo "Downloading the latest version of After Dark ..."
 34   LATEST_META=$(wget -qO - https://registry.npmjs.org/after-dark/latest)
 35   vers=$(echo "$LATEST_META" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 36   mkdir -p themes/after-dark
 37   wget -qO - https://registry.npmjs.org/after-dark/-/after-dark-"$vers".tgz | tar --strip-components=1 -xz -C themes/after-dark
 38   echo "Version $vers downloaded to $SITE_DIR/themes/after-dark"
 39}
 40
 41download_module () {
 42   [ -z "$1" ] && { echo "Error: Attempt to download undefined module" >&2; exit 1; }
 43   echo "Downloading $1 module for After Dark ..."
 44   meta=$(wget -qO - https://registry.npmjs.org/"$1"/latest)
 45   vers=$(echo "$meta" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 46   mkdir -p themes/"$1"
 47   wget -qO - https://registry.npmjs.org/"$1"/-/"$1"-"$vers".tgz | tar --strip-components=1 -xz -C themes/"$1"
 48   echo "Version $vers downloaded to $SITE_DIR/themes/$1"
 49}
 50
 51configure_theme () {
 52   echo "Configuring basic After Dark theme settings ..."
 53   tee "config.toml" > /dev/null <<TOML
 54baseurl = "https://domain.example" # Controls base URL sitewide
 55languageCode = "en-US" # Controls site language
 56title = "After Dark" # Homepage title and page title suffix
 57paginate = 11 # Number of posts to show before paginating
 58
 59# Controls default theme and theme components
 60theme = [
 61  "fractal-forest",
 62  "after-dark"
 63]
 64
 65enableRobotsTXT = true # Suggested, enable robots.txt file
 66
 67pygmentsCodefences = true # Suggested, highlight fenced code blocks
 68pygmentsUseClasses = true # Required for custom syntax highlighting
 69
 70sectionPagesMenu = "main" # Enable menu system for lazy bloggers
 71footnoteReturnLinkContents = "↩" # Provides a nicer footnote return link
 72
 73[params]
 74  description = "" # Suggested, controls default description meta
 75  author = "" # Optional, controls author name display on posts
 76  hide_author = true # Optional, set true to hide author name on posts
 77  show_menu = false # Optional, set true to enable section menu
 78  has_cookies = false # Optional, set true to disable cookie disclaimer
 79  images = [
 80    "https://source.unsplash.com/collection/983219/2000x1322"
 81  ] # Suggested, controls default Open Graph images
 82
 83[params.modules.fractal_forest]
 84  enabled = true # Optional, set false to disable module
 85  decoders = ["bpgdec8a"] # Optional, 8-bit javascript decoder with animation
 86TOML
 87}
 88
 89update_archetypes () {
 90   echo "Updating the default content archetype ..."
 91   rm -f archetypes/default.md
 92   cp themes/after-dark/archetypes/default.md archetypes
 93}
 94
 95create_welcome_post () {
 96   echo "Creating a helpful welcome post ..."
 97   hugo new post/welcome.md 1>/dev/null
 98}
 99
100serve_site () {
101   echo "Starting site server ..."
102   hugo serve --buildDrafts --navigateToChanged --port 1313 1>/dev/null &
103}
104
105generate_help_docs () {
106   echo "Generating help documentation ..."
107   THEME_PATH=themes/after-dark
108   meta_path="$THEME_PATH"/data/npm
109   mkdir -p "$meta_path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
110   cd "$THEME_PATH"/docs && mkdir themes && ln -s ../.. "$THEME_PATH"
111   hugo new validate.md --kind validate 1>/dev/null
112}
113
114serve_help () {
115   echo "Starting help server ..."
116   hugo serve --disableLiveReload --port 1414 1>/dev/null &
117}
118
119set -e
120
121echo "Welcome to the After Dark quick installer. Press CTRL-C at any time to abort."
122
123validate_hugo
124create_site_dir "$1"
125create_site
126download_theme
127update_archetypes
128download_module "fractal-forest"
129configure_theme
130create_welcome_post
131serve_site
132generate_help_docs
133serve_help
134
135YELLOW='\033[0;33m'
136NC='\033[0m'
137
138printf "${YELLOW}Installation successful!${NC}\n"
139echo "Site created in $SITE_DIR_ABS"
140echo "Site server started at http://localhost:1313/"
141echo "To stop it run \"kill \$(ps aux | awk '/[h]ugo.*1313/ {print \$2}')\"."
142echo "Help server started at http://localhost:1414/"
143echo "To stop and restart it run \"./themes/after-dark/bin/help\"."
144echo "Thank you for choosing After Dark."

Please install Hugo 0.44 or greater before running the script.

Script has been tested on Debian, BusyBox and Darwin, and should also work under Alpine, Ubuntu, Docker and Windows via Cmder without additional dependencies.

Warning: Always examine scripts downloaded from the internet before running them locally. If you’d prefer not to run the script Download Manually.

Run the script however you like. Here are three possible methods:

  1. Download and pipe to sh directly:

    wget -qO - https://go.habd.as/after-dark | sh

    (Cojones not included.)

  2. Download into new file, chmod and execute:

    curl -O https://cdn.jsdelivr.net/npm/after-dark@latest/bin/install && \
    chmod +x install && ./install

    (It’s safe if it comes from a CDN, amirite?)

  3. From canonical git clone:

    # clone source and change to source directory
    git clone https://git.habd.as/comfusion/after-dark.git && cd "$_"
    
    # use npm cli to get the release hash
    echo "${$(npm run integrity)#*sha512-}"
    
    # run quick install after validating
    ./bin/install

    (Release Hashes may be used for code validation.)

Script should complete in 5-10 seconds resulting in a sample site and help docs:

After Dark screenshots
After Dark Quick Install running to completion in Terminal on macOS Mojave.

Multi-site Configuration

After Dark enables multi-site management from a single installation. To manage multiple websites use the -c and -d flags to specify the content and destination directories, respectively

For example, to generate an audio site using the current After Dark installation create an executable script to generate the site:

flying-toasters/bin/gen-audio-site
#!/bin/sh
hugo -c sites/audio -d public/audio.domain.example

Where audio contains the content for that site:

├── layouts
├── sites
│   └── audio
│       ├── audiobooks
│       │   ├── gaining-currency.md
│       │   └── the-power-of-now.md
│       └── clips
│           └── war-of-the-worlds.md
├── static

And public contains a folder for each site:

public
└── audio.balibebas.com
    ├── categories
    │   └── index.xml
    ├── audiobooks
    │   └── index.html
    ├── clips
    │   └── index.html
    ├── css
    ├── index.html
    ├── index.xml
    ├── js
    ├── sitemap.xml
    └── tags
        └── index.xml

And create a another script to serve the content for editing:

flying-toasters/bin/serve-audio-site
#!/bin/sh
hugo -c sites/audio

Each subdirectory of public then becomes an independent, deployable website and exact copy save for destination content generated.

Tip: For additional flexibility type hugo --help and modify your scripts using the --theme and --config flags.

Multi-site is perfect for maintaining a consistent look-and-feel across multiple domain origins while limiting the need to run the Upgrade Script for each site.

Connecting to server…
0 hashes (0 h/s)