Deploy Hexo with Bantam CLI
A fast, simple & powerful blog framework
Quick start:
# Build your Hexo app
hexo generate
# Deploy it
bantam deploy public
Quick Start
Install dependencies
Install Hexo and theme dependencies
npm install
Generate static files
Build your blog to static HTML
hexo generate
Deploy with Bantam
Your Hexo blog is now live!
bantam deploy public
Framework Details
Hexo Configuration
Configure Hexo for production deployment:
_config.yml:
# Site
title: My Hexo Blog
subtitle: 'A blog about tech'
description: 'Technical articles and tutorials'
author: Your Name
language: en
timezone: 'America/New_York'
# URL
url: https://myblog.bantam.host
root: /
permalink: :year/:month/:day/:title/
# Directory
source_dir: source
public_dir: public
# Writing
new_post_name: :title.md
default_layout: post
render_drafts: false
# Theme
theme: landscape
Theme Configuration
Install and configure themes:
Install a theme:
# Clone theme to themes directory
git clone https://github.com/theme/hexo-theme-next themes/next
# Update _config.yml
theme: next
Theme config (themes/next/_config.yml):
# Menu
menu:
home: / || fa fa-home
archives: /archives/ || fa fa-archive
tags: /tags/ || fa fa-tags
about: /about/ || fa fa-user
# Social links
social:
GitHub: https://github.com/username || fab fa-github
Twitter: https://twitter.com/username || fab fa-twitter
Build Output
Hexo generates a complete static blog in the public
directory:
index.html
- Blog homepage with postsarchives/
- Archive pages by datecategories/
- Category listing pagestags/
- Tag listing pages2024/01/15/post-title/
- Individual postscss/
andjs/
- Theme assets
Advanced Usage
Custom Domain
Deploy directly to your own domain
bantam deploy ./dist --domain myapp.com
Permanent Deployment
Keep your site online forever (requires login)
bantam deploy ./dist --permanent
Custom Expiry
Set how long your deployment stays online
bantam deploy ./dist --expiry-days 7
Custom Subdomain
Choose your own subdomain on bantam.site
bantam deploy ./dist --subdomain my-project
CI/CD Integration
Add Bantam to your continuous deployment pipeline:
# GitHub Actions example
- name: Deploy to Bantam
run: |
npm install -g @bantamhq/cli
bantam login --token ${{ secrets.BANTAM_TOKEN }}
bantam deploy ./dist --domain myapp.com --permanent
Common Issues & Solutions
Quick fixes for deployment challenges
01.Theme not loading properly?
Clean and rebuild with theme:
hexo clean
rm -rf node_modules
npm install
hexo generate
Verify theme is in themes directory:
ls themes/
# Should show: your-theme-name
02.Posts not showing up?
Check post front matter format:
---
title: My Post Title
date: 2024-01-15 14:30:00
tags:
- javascript
- tutorial
categories:
- Development
---
Post content here...
Ensure posts are in source/_posts directory
03.Asset paths broken in production?
Use Hexo's asset helpers:
<!-- In templates -->
<%- css('css/style') %>
<%- js('js/script') %>
<!-- For images in posts -->
{% asset_img example.jpg "Image description" %}
<!-- Or use asset folders -->
_config.yml:
post_asset_folder: true
04.Deployment showing old content?
Clean build directory before generating:
# Clean and rebuild
hexo clean && hexo generate
# Or use npm scripts
"scripts": {
"build": "hexo clean && hexo generate",
"deploy": "npm run build && bantam deploy public"
}
05.How to add custom pages?
Create pages with hexo new page:
# Create about page
hexo new page about
# Creates source/about/index.md
---
title: About
date: 2024-01-15
---
About page content...