Hexo Change Default to Page
Concept
- First we need understand how Hexo’s blog page works.
- By default, Hexo will create a blog page that will showcase all your posts. Refer to this.
- Hexo creates a
index.html, which is your blog page, when deploy usinghexo dorhexo deploy. - This is all based on the pre-installed module
hexo-generator-index, which you can config under_config.ymlfile:
1 | index_generator: |
- the value from
pathadds suffix to your website url.
If you want to display your custom page by default instead of the “blog page”, follow steps below.
- Deploy your blog page somewhere else.
- Go to file
_config.yml, find these lines:1
2
3
4index_generator:
path: ''
per_page: 10
order_by: -date - Edit value in
path, for example I change to follow:1
2
3
4index_generator:
path: 'blog'
per_page: 10
order_by: -date- This will create the blog page inside a
blogdirectory, frompath: 'blog'. - Now if you want to access your blog page, just visit “your_website_url/blog/“. For example, my website is “https://jacklee981229.github.io/“, the url to my blog page will be “https://jacklee981229.github.io/blog/“.
- This will create the blog page inside a
- After first step, you will get error when trying to accessing your website’s main url, as the
index.htmlis not auto-generated anymore. Therefore you will need to create aindex.mdfile undersourcefolder manually.
- Create your own default page.
- Create a
index.mdunder source folder. Other naming will require additional works. So we are stick toindex.mdin this case.- Type in
Hello World!in yourindex.md.
- Type in
- You are all set! Run
hexo g&&hexo sand you shall see yourHello World!message.
- You can edit your
index.mdto show all your writings, all your posts and pages. - Visit mine for an idea!
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.