Skip to content

CleverCloud/HexoJS-example

Repository files navigation

Hexo Static Blog Example on Clever Cloud

Clever Cloud - PaaS

This is an example of how to deploy a Hexo static blog on Clever Cloud, using the Node.js runtime.

Hexo is a fast, simple and powerful blog framework that renders Markdown posts into static HTML files. This example serves those generated pages with hexo server and regenerates them on every deployment.

About the Application

This is the default Hexo scaffold using the Landscape theme. It ships with:

  • A sample "Hello World" post under source/_posts/
  • The standard Hexo generators (index, archive, category, tag)
  • EJS, Markdown and Stylus renderers
  • The Landscape theme

The site is served on port 8080, as required by the Clever Cloud Node.js runtime.

Technology Stack

Prerequisites

  • Node.js 24+
  • npm

Running the Application Locally

npm install
npm start

The application will be accessible at http://localhost:8080.

To write content and regenerate the static pages:

npx hexo new "My new post"   # create a new post in source/_posts/
npx hexo generate            # render Markdown into static HTML (public/)
npx hexo clean               # clear the cache and generated files

How it works on Clever Cloud

The server launch is configured in package.json, in the scripts.start field:

hexo server --port 8080 --static
  • Listening on port 8080 is required to deploy on Clever Cloud.
  • The --static option serves only the pages generated by hexo generate. Remove it if you want Hexo to render pages on the fly.

Because --static serves the pre-generated public/ folder (which is not committed), you need to (re)generate it on every deployment with a post-build hook. See the optional step in the deployment instructions below.

Deploying on Clever Cloud

You have two options to deploy your application on Clever Cloud: using the Web Console or using the Clever Tools CLI.

Option 1: Deploy using the Web Console

1. Create an account on Clever Cloud

If you don't already have an account, go to the Clever Cloud console and follow the registration instructions.

2. Set up your application on Clever Cloud

  1. Log in to the Clever Cloud console
  2. Click on "Create" and select "An application"
  3. Choose "Node.js" as the runtime environment
  4. Configure your application settings (name, region, etc.)

3. (Optional) Generate the static pages on each deployment

The default start command runs hexo server --static, which serves only the pages produced by hexo generate. Since the generated public/ folder is not committed, add a post-build hook so the pages are (re)generated on every deployment — otherwise the app will respond with Cannot GET /.

In your application's dashboard, go to Environment variables and add:

CC_POST_BUILD_HOOK = npx hexo generate

Skip this step only if you removed the --static option from the start script.

4. Deploy Your Application

You can deploy your application using Git:

# Add Clever Cloud as a remote repository
git remote add clever git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/app_<your-app-id>.git

# Push your code to deploy
git push clever master

Option 2: Deploy using Clever Tools CLI

1. Install Clever Tools

Install the Clever Tools CLI following the official documentation:

# Using npm
npm install -g clever-tools

# Or using Homebrew (macOS)
brew install clever-tools

2. Log in to your Clever Cloud account

clever login

3. Create a new application

# Initialize the current directory as a Clever Cloud application
clever create --type node <YOUR_APP_NAME>

4. (Optional) Set the scaling

clever scale --min-flavor pico --max-flavor pico
clever scale --min-instances 1 --max-instances 1

More information on scaling in the documentation.

5. (Optional) Generate the static pages on each deployment

The default start command runs hexo server --static, which serves only the pages produced by hexo generate. Since the generated public/ folder is not committed, add a post-build hook so the pages are (re)generated on every deployment — otherwise the app will respond with Cannot GET /:

clever env set CC_POST_BUILD_HOOK "npx hexo generate"

Skip this step only if you removed the --static option from the start script.

6. Deploy your application

clever deploy

7. Open your application in a browser

Once deployed, you can access your application at the URL provided by Clever Cloud.

clever open

Monitoring Your Application

Once deployed, you can monitor your application through:

  • Web Console: The Clever Cloud console provides logs, metrics, and other tools to help you manage your application.
  • CLI: Use clever logs to view application logs and clever status to check the status of your application.

Additional Resources

License

This example is provided under the terms of the MIT license.

About

An example on how to deploy Hexo based website on Clever Cloud

Topics

Resources

Stars

Watchers

Forks

Contributors