Hexo: Blog entries in a subfolder, custom home page

Created on 23 May 2016  路  10Comments  路  Source: hexojs/hexo

Is it possible to have all blog entries in a subfolder, that is, blog to be just a part of a site, and /index.html just a custom page? I can configure permalinks, tags, pages, etc. to be generate in, for example, /blog subfolder. But blog index is still hardcoded to be /index.html, right?

If that's not currently possible, can you point me to where I should start looking to change it in the code?

stale wontfix

Most helpful comment

I've created a PR that adds a config option to the hexo-generator-index package. https://github.com/hexojs/hexo-generator-index/pull/7

All 10 comments

It seems the only change I had to make is in hexo-generator-index/lib/generator.js on line 10 from '' to, for example, 'blog'. And then create /index.html just as a normal page. Maybe this can be made a configuration option?

You can just change the "url" and "root" in config to put all your blog into one subfolder.

Or you can create a .md file into your favorite folder with specific layout placed in your theme, but at the cost of losing accessibility of properties related to pagination(for hexo will still treat it as an PAGE).

For full customization, you have to write your own generator(maybe with new local variables calculated by yourself) and register it into hexo.

@zyzyz If I change root, then entire hexo-generated site will be in that folder, while I want just the blog in a subfolder. Basically, I want to use hexo not just for blogging but for my entire site (to share templates, etc.), and I need home page to be just a normal page, not blog index.

Anyway, my change in hexo-generator-index/lib/generator.js seems to work - pagination and everything work as expected.

@pronvit you can try to change the post permalink

For others to be clear on the change @pronvit made. in hexo-generator-index/lib/generator.js change return pagination('', posts, { to return pagination('blog', posts, {

You will then need to run hexo generate then restart the hexo server (if already started)

To get the "blog" showing up in the menu modify the themes/<theme_name>/config.yml Mine looks like:

menu:
  Home: /
  Blog: /blog
  Archives: /archives

Note I don't explicitly have a source/blog page.

I've created a PR that adds a config option to the hexo-generator-index package. https://github.com/hexojs/hexo-generator-index/pull/7

Thanks @rgfindl, that works like a charm. A tiny modification in hexo-generator-index package that increases Hexo functionality a lot.

@pronvit @davidmtobias npm package has updated accordingly. New version is 0.2.1.

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakeg picture jakeg  路  3Comments

yunTerry picture yunTerry  路  3Comments

awulkan picture awulkan  路  3Comments

hjmJhon picture hjmJhon  路  3Comments

19uni94 picture 19uni94  路  3Comments