Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

phen0menon/hexo-with-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Hexo with Express.js and develop fast, simple and flexible websites

Quick Start

  1. Make sure that you have Node.js v8 or above installed.
  2. Clone this repo using git clone https://github.com/phen0menon/hexo-with-express.git
  3. Move to the appropriate directory: cd hexo-with-express/blog.
  4. Run npm install in order to install dependencies.
  5. Run hexo generate in order to generate Hexo's public files.
  6. Move to the root directory of the project: cd ../
  7. Run npm install in order to install project-root dependencies.

At this point you can run npm run start to see the example app at http://localhost:4000

Guide

When you edit your blog and want to see some changes, use hexo generate in order to create public HTML files and see them on your Express.js server.

Important: Don't forget to restart the server.

How to add modules to the project

You will need to add other modules to this project, depending on your purposes. For example, you may want to add node-postgres to communicate with PostgreSQL database.

Please read the following section before installing any dependencies

Module structure

This project uses a two package.json project structure. This means, you will have two package.json files.

  1. ./package.json in the root of your project
  2. ./blog/package.json inside blog folder

Which package.json file to use

  1. If the module connects with Hexo platform, it should be listed under dependencies in ./blog/package.json
  2. Modules used for developing (like node-postgres) should be included in dependencies in ./package.json
  3. Modules used for building, testing and debugging should be included in devDependencies in ./package.json

Change URL route of blog

If you want to change url route of blog, for example, you want to change route like this: http://domain.com/blog

Please read the following section before doing anything.

Step-by-step guide

  1. Go to hexo-with-express/blog and open _config.yml file. Find URL section and change the following:
url: http://localhost:4000/your_blog_dir
root: /your_blog_dir
  1. In this folder run hexo generate.
  2. Go to hexo-with-express/ and open index.js. Change the following:
app.use('/your_blog_dir', express.static('blog/public'));
  1. Restart the server to apply the changes.
  2. Open http://localhost:4000/your_blog_dir.

Credits

This project bootstrapped with: Hexo, Express.js
Made with ❤️ for Hexo

About

Connected Hexo platform with Express.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published