11

In the theme _config.yml has two default route: / and /archieves. Is there possible to add a route like /about?

I tried to add /about in _config.yml, but Cannot GET /about/ shows.

Leo Gao
  • 629
  • 1
  • 6
  • 17

4 Answers4

21

You have to create a new page by runnning hexo new page "about". A folder will be created in source/. In this folder, there is a file named index.md. In this file, you can write the content of this page /about in markdown.

This page will be displayed as a post page layout, if you want an other layout and style, define in front-matter, the layout with layout: YOUR_LAYOUT. Of course, you have to create this layout in the layout folder of your theme folder. The layout name will be the name of the file.

JrBenito
  • 973
  • 8
  • 30
Louis Barranqueiro
  • 10,058
  • 6
  • 42
  • 52
14

If you need a page about :

  1. run hexo new page "about"

  2. You will find an about folder in the source folder. You can edit the index.md file in the about folder.

  3. add code About: /about in the menu section of _config.yml file in your theme folder. Preview your site :)

Jun
  • 141
  • 1
  • 3
2

If you need a page about,you can run hexo new page 'about',and then add /about in _config.yml

ntalbs
  • 28,700
  • 8
  • 66
  • 83
B.Y.JFF
  • 66
  • 3
2

Three years passed, but maybe someone will find this useful.

If you want to actually add a route (without creating a page directory and/or files) you can use generator. Add this to a .js file inside your theme's scripts folder:

hexo.extend.generator.register("all-posts", function(locals) {
  return {
    path: "all-posts/index.html",
    data: locals,
    layout: ["all-posts", "index"]
  };
});

In this example, the page with layout 'all-posts' will be at /all-posts url.

This, of course, could be done by creating a folder with index.md file in it, with layout: all-posts in its front-matter

Ilia Andrienko
  • 284
  • 1
  • 12