1

I recently decided to start a small blog for personal use (for now) on Azure. I started digging into the blogging framework Hexo. Now i got the (first) basics under control with starting a Hexo blog locally, but i want to push it to Azure.

I configured a basic web-app with a GIT connection for continuous deployment (https://github.com/lmeijdam/demo-repo). I tried a tutorial with a

  • server.js file
  • package.json
  • .gitignore

Above will result in a working response and installed node_modules... But from there i am really lost about my next steps...

I know you can create a package.json file and viewing my ftp client the package.json is there and also the node_modules folder with the correct modules installed. My package.json;

{ "name": "hexo-site", "version": "0.0.0", "private": true, "hexo": { "version": "3.1.1" }, "dependencies": { "express": "*", "hexo": "^3.1.0", "hexo-deployer-git": "0.0.4", "hexo-generator-archive": "^0.1.2", "hexo-generator-category": "^0.1.2", "hexo-generator-index": "^0.1.2", "hexo-generator-tag": "^0.1.1", "hexo-renderer-ejs": "^0.1.0", "hexo-renderer-marked": "^0.2.4", "hexo-renderer-stylus": "^0.3.0", "hexo-server": "^0.1.2" } }

and i also found out you can deploy a Procfile to the GIT repo which Azure then uses, if you have no default file called server.js (https://github.com/yavorg/azure-node-starter/blob/master/Procfile)

And later a friend came with the tip to edit the procfile to write something like;

web: /node_modules/hexo/bin/hexo server instead of just the web: node server.js

unfortunately this just results in a default blanco webpage... http://lmnodetest1.azurewebsites.net/

Am i doing stuff wrong here or am i forgetting something at the start?

Lars Meijdam
  • 1,177
  • 1
  • 10
  • 18

4 Answers4

3

Per my experience, Hexo is a static blog website generator. You can follow these steps below to generate a website at the path "public".

$ hexo init blog
$ cd blog
$ npm install
$ hexo generate

Then, the "public" directory generated, and you can entry into this directory and run the command hexo server to browse http://localhost:4000 to explore your blog.

$ cd public
$ hexo server

For deploying the blog into Azure Website by using Git, you just need to create a local git repo by commanding git init at the "public" dir.

Please refer to the doc https://azure.microsoft.com/en-us/documentation/articles/web-sites-deploy/ to deploy it into Azure.

Best Regards.

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
3

Here are the steps that I do to run Hexo blog on Azure: http://the-coderok.azurewebsites.net/2015/09/16/Running-Hexo-blog-on-Azure/

vmg
  • 9,920
  • 13
  • 61
  • 90
2

It seems to me that the best part about using hexo is as a static site generator. The hexo server is really meant to give you a nice development environment where you can see your posts right away, but if you're publishing your site you'd wanna serve the statically generated content to remove node from the picture.

Hexo has hexo generate for that and you can get that to work nicely with Azure if you have a custom deployment script.

Here is a repo with 2 commits that you can git push to an empty site and it'll create a working static hexo blog:

  1. First commit is just the result of hexo init blog
  2. Second commit is the custom deployment script. You'd want to copy these 2 files to your own repo.

here is the exact parts that you'd need in your deploy.cmd for hexo.

note that the actual script in the repo has way more lines for proper error handling but this is just the gist of what you need

echo Handling Hexo deployment.

IF NOT DEFINED HEXO_PATH (
   echo Setting HEXO_PATH to %HOME%\npm_tools\hexo.cmd
   set HEXO_PATH="%HOME%\npm_tools\hexo.cmd"
)

IF NOT EXIST %HEXO_PATH% (
  echo Hexo CLI isn't installed. Running 'npm install hexo-cli -g'
  mkdir "%HOME%\npm_tools"
  npm config set prefix "%HOME%\npm_tools"
  npm install -g hexo-cli
)

echo Running 'npm install --production'
npm install --production

echo Running 'hexo generate'
%HEXO_PATH% generate

echo Copying static content to site root
"%KUDU_SYNC_CMD%" -v 50 -f "public" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
ahmelsayed
  • 7,125
  • 3
  • 28
  • 40
  • On azure, you can skip installing the hexo-cli globally because npm installed a binary in node_modules already - so change the generate command to `call :ExecuteCmd node_modules/.bin/hexo generate`. Also it's important to note you will have to change the default root virtual directory in the App Settings to point to `site\wwwroot\public\` since that's where hexo puts the static files. – sirtimbly Aug 09 '17 at 14:44
0

I took a quick look at your site. The issue appears to be that you have a server2.js file but no server.js file. Can you try renaming it in your repo and pushing again? That should at least get you past the first hurdle.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117