New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static, rendered homepage instead of blog #1491

Closed
simonh1000 opened this Issue Sep 8, 2015 · 10 comments

Comments

9 participants
@simonh1000
Copy link

simonh1000 commented Sep 8, 2015

I have read (#654) but the instructions no longer work it seems. But my question is slightly different.

How can I have a page that is rendered by Hexo (i.e. with the themes headers and footer etc) from markdown but set as the home (landing) page with the blog element put in a directory /blog

@Ehesp

This comment has been minimized.

Copy link

Ehesp commented Sep 10, 2015

Exact same question ^^

@gleb-svechnikov

This comment has been minimized.

Copy link

gleb-svechnikov commented Sep 13, 2015

You need to create index.md file with static content in your source folder. Also for latest version of Hexo(^3.1.1) you'll need to remove hexo-generator-index from dependencies in package.json.

@dnosker

This comment has been minimized.

Copy link

dnosker commented Sep 19, 2015

This worked perfectly for me.
Perhaps this could be closed.

@ChongTang

This comment has been minimized.

Copy link

ChongTang commented Oct 21, 2015

@dnosker Hi, how do you make the custom homepage work? I removed the hexo-generator-index dependency from package.json, and added index.md in source folder. But I got some errors from theme's .ejs files when I run "hexo generate" command. I guess it might the theme's problem. I tried several different theme, but got the same problem. Which theme are you using? Thanks!

@leesei

This comment has been minimized.

Copy link
Member

leesei commented Nov 13, 2015

@ChongTang Did you uninstall hexo-generator-index?
npm uninstall --save hexo-generator-index

@johot

This comment has been minimized.

Copy link

johot commented Jul 10, 2017

I got this working after finding this issue. To clarify:

  • Do an npm uninstall --save hexo-generator-index
  • Add an index.md file to the root of your source folder.

Now the index page will behave like a normal page so you can for example in your index.ejs file have:
<%- page.content %>

Hope this helps :)

@knafteN

This comment has been minimized.

Copy link

knafteN commented Jul 21, 2017

I just initialized a fresh hexo app and followed the steps provided by @johot.
The generated /public/index.html looks okay, but when I start the server via hexo server it will redirect me to localhost:4000/blog which does not exist.
Any ideas?

@NoahDragon

This comment has been minimized.

Copy link
Member

NoahDragon commented Jul 24, 2017

@knafteN Please check the config, maybe you have set the default url to blog.

BTW, if a closed issue doesn't answer your question, please create a new issue and link to the closed one. Thanks.

@johot

This comment has been minimized.

Copy link

johot commented Jul 24, 2017

In my _config.yml I have set root to: / and also added this:

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

And finally in the source folder (the root) I have added an index.md file, I did not need to change it's permalink or anything.

Maybe you set your root wrong @knafteN ?

@knafteN

This comment has been minimized.

Copy link

knafteN commented Jul 25, 2017

@johot @NoahDragon I tried both, but still no luck. So I opened up a new issue and pushed my stuff into a public repository so you guys can check #2663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment