iissnan / hexo-theme-next

Elegant theme for Hexo.
http://notes.iissnan.com
MIT License
15.88k stars 3.62k forks source link

How to make a custom homepage within the theme #1776

Closed Lastcysa closed 7 years ago

Lastcysa commented 7 years ago

Hi, I am new to next. I want to show a simple self-introduction as the homepage. Now the default homepage is a list of blogs. I want to know how I can make a custom homepage with a single markdown file.

For example, my site url is abc.com, I want abc.com to be my "about me" page, while abc.com/blogs to be a summary of blogs (just like the original index page)

I suspect it's necessary to modify index.swig, but I have no idea how to do it.

Here is a perfect example of what I want to achieve:.

Thanks very much.

ivan-nginx commented 7 years ago

This can make with hexo-generator-index2.

index_generator:
    per_page: 10
    order_by: date
    include:
#       - category CATEGORY
        - path PERMALINK
#   exclude:
#       - tag TAG
Lastcysa commented 7 years ago

@ivan-nginx

Thank you for your help, but I still cannot get it right.

I tried hexo-generator-index2 and set the include filed as

  include:
    - path abc.com/about/

However it returns 404 error when my homepage is accessed.

ivan-nginx commented 7 years ago

U must set permalink path.

  include:
    - path about

about.md:

---
permalink: about
title: ...
date: ...
...
Lastcysa commented 7 years ago

Tried again as you suggested. But still 404 error. I checked public folder and found that there's no index.html generated

ivan-nginx commented 7 years ago

So, about page must open by site.com/about/ and no give 404 error. If is it, then u do something not right. Link on demo site & link on src.


Try to set in about.md:

permalink: about/index.html
Lastcysa commented 7 years ago

I solved the problem in this way without using hexo-generator-index2:

set the permalink of about page as index, then do the following:

index_generator:
  path: /blog/

Anyway, thanks @ivan-nginx , your efforts and patience are very much appreciated.

ivan-nginx commented 7 years ago

@Lastcysa wow! I don't know that. Well done! Ok, if solved, close it please.

Harrypotterrrr commented 5 years ago

I solved the problem in this way without using hexo-generator-index2:

set the permalink of about page as index, then do the following:

index_generator:
  path: /blog/

Anyway, thanks @ivan-nginx , your efforts and patience are very much appreciated.

I have the same problem as you, that I hope to set my homepage as about instead of blog However, I don't know how to set the permalink of about page as index Could you help me with this? I have no idea about this.

Lastcysa commented 5 years ago

I solved the problem in this way without using hexo-generator-index2: set the permalink of about page as index, then do the following:

index_generator:
  path: /blog/

Anyway, thanks @ivan-nginx , your efforts and patience are very much appreciated.

I have the same problem as you, that I hope to set my homepage as about instead of blog However, I don't know how to set the permalink of about page as index Could you help me with this? I have no idea about this.

  1. locate to hexo/_config.yml and find the path field in index_generator.
  2. locate to hexo\source\about\index.md, and then you should find the permalink field.

It was a long time ago so I'm not sure if it still works in this way now. Hope it helps.

Harrypotterrrr commented 5 years ago

I solved the problem in this way without using hexo-generator-index2: set the permalink of about page as index, then do the following:

index_generator:
  path: /blog/

Anyway, thanks @ivan-nginx , your efforts and patience are very much appreciated.

I have the same problem as you, that I hope to set my homepage as about instead of blog However, I don't know how to set the permalink of about page as index Could you help me with this? I have no idea about this.

  1. locate to hexo/_config.yml and find the path field in index_generator.
  2. locate to hexo\source\about\index.md, and then you should find the permalink field.

It was a long time ago so I'm not sure if it still works in this way now. Hope it helps.

Thanks for your instant reply, I have filled /about/ in hexo/_config.yml, showed as below,

index_generator:
  path: '/about/'
  per_page: 10
  order_by: -date

For the second step, you told me to locate to hexo\source\about\index.md, and find the permalink field, I filled permalink like this,

---
title: Curriculum vitae
date: 2019-04-07 07:24:52
comments: false
permalink: index.html
---

This works out, but there is another problem that I can't find the previous homepage, in other words, I think the previous homepage HTML isn't generated, is it? I am a freshman in front-end tech, thanks for your patience.. ☀️