hexo icon indicating copy to clipboard operation
hexo copied to clipboard

Running hexo on an express /blog route on heorku

Open northcoders-chris opened this issue 10 years ago • 6 comments

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?

northcoders-chris avatar Mar 07 '16 17:03 northcoders-chris

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

northcoders-chris avatar Mar 07 '16 17:03 northcoders-chris

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

leesei avatar Mar 08 '16 05:03 leesei

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?

northcoders-chris avatar Mar 08 '16 07:03 northcoders-chris

Sorted :) Thanks a lot

northcoders-chris avatar Mar 08 '16 13:03 northcoders-chris

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

leesei avatar Mar 08 '16 15:03 leesei

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 :)

laurentdebricon avatar Mar 16 '16 10:03 laurentdebricon