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

How to put post Markdown file into asset folder? #3245

Open
AlynxZhou opened this Issue Aug 29, 2018 · 0 comments

Comments

2 participants
@AlynxZhou

AlynxZhou commented Aug 29, 2018

Environment Info

Node version(node -v): v10.9.0 This doesn't matter.

Your site _config.yml (Optional): I will describe it later.

Your theme _config.yml (Optional): This doesn't matter.

Hexo and Plugin version(npm ls --depth 0):

hexo-site@0.0.0 /home/alynx/stackharbor.alynx.xyz
├── hexo@3.7.1
├── hexo-blog-encrypt@2.0.7
├── hexo-deployer-git@0.3.1
├── hexo-deployer-heroku@0.1.2
├── hexo-deployer-rsync@0.1.3
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-feed@1.2.2
├── hexo-generator-index@0.2.1
├── hexo-generator-search@2.2.5
├── hexo-generator-sitemap@1.2.0
├── hexo-generator-tag@0.2.0
├── hexo-neat@1.0.4
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-marked@0.3.2
├── hexo-renderer-njucks@1.0.0
├── hexo-renderer-stylus@0.3.3
└── hexo-server@0.2.2

For question

We all know that by default when Hexo create a post with asset folder, it creates a :title.md file and a :title/ folder in _posts/, and in generating your :title.md file will be moved to :title/index.html.

However, this is REALLY REALLY anti-human and anti-editor. Because Hexo changes route while generating (your post .md source path is NOT public path), all editor cannot find the image link or other asset link, and none of them can read Hexo's {% asset_img %} tag.

Normal config:

new_post_name: :title.md
post_asset_folder: true

Current Hexo post dir structure:

_posts/
    |
    - Some-Title.md
    |
    - Some-Title/
        |
        - Assets of Some-Title

If we can make it the same, I mean, the path in source dir will be the same in public dir, like your Markdown file will be put as :title/index.md and your asset folder is just the :title/, it will be better in all conditions. I think other staticf generator except Hexo uses this better way.

Better structure:

_posts/
      |
      - Some-Title/
          |
          - index.md (Markdown file of this post)
          |
          - Assets of Some-Title

I have tried change config to do this. First I set my config like this:

new_post_name: :title/index.md
post_asset_folder: true

But it causes this:

_posts/
      |
      - Some-Title/
          |
          - index.md (Markdown file of this post)
          |
          - index/ (Hexo make another silly asset folder!)
              |
              - Assets of Some-Title

And then I changed this:

post_asset_folder: false

It ignored asset file like this:

_posts/
      |
      - Some-Title/
          |
          - index.md (Markdown file of this post)
          |
          - Assets of Some-Title was IGNORED!!!

For feature request

I think there is a historical reason for Hexo to use such a bad way to deal it, and we should make it better. In face I think if we keep behavior right now but generate not only post Markdown files but also other files together with this Markdown file, we can make it better by just set existing config like:

new_post_name: :title/index.md
post_asset_folder: false

And get a structure like:

_posts/
      |
      - Some-Title/
          |
          - index.md (Markdown file of this post)
          |
          - DO NOT ignore Assets of Some-Title here

It will be better.

PS: I can use English to express my thought in most cases of coding, but a complex issue like this is hard to describe, so if there are developers speaking Chinese well we can communicate in Chinese and then translate into English to make it clearly. Thank you.

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