Hexo: Running hexo on an express /blog route on heorku

Created on 7 Mar 2016  路  6Comments  路  Source: hexojs/hexo

Hi Guys

I am loveing Hexo!! I was hoping you could point me in the right direction of a way to run hexo on my actual express server so when the user requests /blog it serves up hexo as it does on / when i run it with the global hexo server command locally?

Most helpful comment

If you have already a pretty full public folder because of your express website :
With the help of this guide : http://expressjs.com/en/starter/static-files.html you can add a new static folder, and express will lookup for files in the order you register the calls

so you will have

app.use(express.static('public'));
app.use('/blog', express.static('hexo/public')); 

(it's like mounting a directory in linux)

It feels clean :)

All 6 comments

I have an express website running on heroku and wanted to add the blog to /blog on heroku

Just generate the Hexo site, copy public/ as blog/ in your express site's static folder.

Ok I have out my hexo site in public but what does it need to do in the route on /blog? I do not realy understand the entry point to the hexo blog or what happens when you run hexo server. I must need to get it running or call some javascript to render the blog on /blog route?

Sorted :) Thanks a lot

Hexo generate _static_ HTML and requires no integration on the host.
Enjoy.

If you have already a pretty full public folder because of your express website :
With the help of this guide : http://expressjs.com/en/starter/static-files.html you can add a new static folder, and express will lookup for files in the order you register the calls

so you will have

app.use(express.static('public'));
app.use('/blog', express.static('hexo/public')); 

(it's like mounting a directory in linux)

It feels clean :)

Was this page helpful?
0 / 5 - 0 ratings