Hugo
If you need an example source code, use Theme mini (you’ll need git and Hugo):
git clone https://github.com/nodejh/hugo-theme-mini myStaticApp
Create a static application
You can create an application in our Console or through Clever Tools:
npm i -g clever-tools
clever login
cd myStaticApp
clever create -t static-apache myStaticApp
To deploy on Clever Cloud, your local folder need to be a git repository (if not, git init
) linked to an application. If you already have an application on Clever Cloud and want to link it to the current local folder:
clever link your_app_name_or_ID
Configure environment variables and deploy script
Next, configure the application with a medium build instance to quickly generate static files. The host instance is nano-sized, enough for a simple website. As Clever Cloud is based on standards, you only need to define a few variables:
clever scale --build-flavor M
clever scale --flavor nano
clever env set CC_WEBROOT "/public"
clever env set CC_OVERRIDE_BUILDCACHE "/public"
clever env set CC_PRE_BUILD_HOOK "bash setup_hugo.sh"
clever env set CC_POST_BUILD_HOOK "hugo --minify --gc"
Edit the deploy script (setup_hugo.sh
) with this content:
HUGO_VERSION="0.121.1"
HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz"
DEST_BIN="${HOME}/.local/bin"
FILENAME="hugo.tar.gz"
# Download Hugo Extended and place it in a folder in the $PATH
curl --create-dirs -s -L -o ${DEST_BIN}/${FILENAME} ${HUGO_URL}
cd ${DEST_BIN}
tar xvf ${FILENAME} -C ${DEST_BIN}
rm ${FILENAME}
Push your code
Once you complete these steps, commit your content to the local repository and deploy it:
git add .
git commit -m "First deploy"
clever deploy
clever open
You can display your website’s URL or add a custom domain to it (you’ll need to configure DNS):
clever domain
clever domain add your.website.tld
404 Redirections
Since your are using CC_WEBROOT
environment variable, this is where Apache is going to looks for directives. To allow redirecting to your 404.html
theme or custom page in Hugo, put the following .htaccess
file in your /static
folder :
RewriteEngine On
ErrorDocument 404 /404.html
This file will be copied to the root of your web server in /public
on build.
Did this documentation help you ?