Search code examples
hexo

Hexo - how can you set page path?


I see hexo builds paths by convention of the file layout. Though I wish to organize files differently. Is there a way to set paths manually in page files?

E.g. source/abt.md:

title: About me
path: '/about/me/'

Solution

  • Actually, it's possible using the --path option:

    hexo new page --path about/me/index "About me"
    

    this will create source/about/me/index.md file with the following front matter:

    ---
    title: About me
    date: 2019-04-04 23:51:44
    ---
    

    The --path option is not documented, but it is listed when using hexo help new.

    By the way, the help for hexo new command states:

    Usage: hexo new [layout] <title>
    

    This means that the path is automatically defined from the title. Using --path option simply allows to specify it manually.

    Note that not giving a title on the command line creates a post. For instance:

    hexo new page --path foo/bar
    

    will create _posts/foo/bar.md with front matter title set to page. It's not a bug: the layout is optional, while the title is not.