2

I made a blog with hexo and wrote an article in markdown. I ran hexo server and saw the changes on localhost:4000, but when I ran hexo generate and tried to open the index.html file in the public/ folder, it appeared completely barebones

Isn't the publish folder supposed to resemble the localhost:4000 site?

A_toaster
  • 1,196
  • 3
  • 22
  • 50

2 Answers2

2

Here are the steps to make it work:

As stated in the docs, run these commands to start a new blog:

$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo server

At this point your site will be running with the dev server.

Now shut down the dev server and use

$ hexo generate

to generate the source files (in the /public folder)

At this point, if you simply open the index.html in Chrome (or any other browser), it won't work because the paths to the external resources are broken.

You need to host the files on a web server of some sort. If you don't already have apache running somewhere on your machine, here is a quick way to run a node static web server:

$ npm -g install static-server

will install a simple http server to serve static resource files from a local directory.

then navigate to your public folder:

$ cd public

and start off the web server:

$ static-server

Open your browser at http://localhost:9080 and your site should be up and running.

klugjo
  • 19,422
  • 8
  • 57
  • 75
  • My bad, I did run `hexo generate`, but I put publish in the title. Edited the question just now to reflect that – A_toaster Jan 22 '18 at 08:28
  • yes then it should look the same. Did you check that the files inside the `public` folder were actually modified ? – klugjo Jan 22 '18 at 08:35
  • Yeah, the files are modified, I can actually see the post that I made, but it looks like the phase only contains html and no css or js – A_toaster Jan 22 '18 at 08:36
  • page* not phase – A_toaster Jan 22 '18 at 08:45
  • ok that's really weird, not sure how to help. Maybe just start again and follow all the steps on the official docs ... – klugjo Jan 22 '18 at 09:13
  • I think I have found the issue, but am unable to resolve it. The website that is generated has many broken links. In the Chrome console it has a lot of `FILE NOT FOUND` errors. Is there a setting somewhere that I can change to fix this? – A_toaster Jan 23 '18 at 08:27
  • eg it says /css/style.css NOT FOUND. My config.yml is default, I haven't changed anything there – A_toaster Jan 23 '18 at 08:28
0

The link you provided has the site in a subdirectory, not in the root directory. In your config.yaml file you will see a parameter for both url and root that you need to set to reflect your live site.