hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.3k stars 4.83k forks source link

Is it possible to put articles inside "Post Asset Folder"? #4768

Closed maple3142 closed 2 years ago

maple3142 commented 3 years ago

Check List

Please check followings before submitting a new issue.

Question

This page said you can use Post Asset Folder to structure your posts like this:

source/_posts
├── article1.md
├── article1
│   ├── img1.png
│   └── img2.png
├── article2.md
├── article2
│   ├── img1.png
│   └── img2.png

Images are always referenced using ![alt](img1.png), no Hexo specific markups are used

And this what I am currently using. The problem is this is getting messier with the number of the posts increasing, and it is not friendly to VSCode's markdown preview either. (Unable to display images)

I think these problems could be solved if it can be reorganized like this:

source/_posts
├── article1
│   ├── index.md
│   ├── img1.png
│   └── img2.png
├── article2
│   ├── index.md
│   ├── img1.png
│   └── img2.png

Each article belongs to index.md in their Post Asset Folder.

I tried to do this, but the problem is Hexo will generate the html in this structure:

2021/08/29
└── article1
    └── index
        └── index.html

Assuming permalink is :year/:month/:day/:title/

It if possible to make it generate the following strucutre while using the latter one (index.md method)?

2021/08/29
└── article1
    └── index.html
    └── img1.png
    └── img2.png

Environment & Settings

Node.js & npm version

node: v16.6.0
npm: 7.19.1

Your site _config.yml (Optional)

Your theme _config.yml (Optional)

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

├── @next-theme/plugins@8.7.1
├── graceful-fs@4.2.8
├── gulp-csso@4.0.1
├── gulp-dom@1.0.0
├── gulp-html-minifier-terser@6.0.1
├── gulp-imagemin@8.0.0
├── gulp-pretty-data@0.2.0
├── gulp-terser@2.0.1
├── gulp-uglify@3.0.2
├── gulp@4.0.2
├── hexo-filter-mathjax@0.7.1
├── hexo-fs@3.1.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-feed@3.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-restful@0.2.3
├── hexo-generator-robotstxt@0.2.0
├── hexo-generator-search@2.4.3
├── hexo-generator-sitemap@2.1.0
├── hexo-generator-tag@1.0.0
├── hexo-related-popular-posts@5.0.1
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-pandoc@0.3.0
├── hexo-renderer-stylus@2.0.1
├── hexo-server@2.0.0
├── hexo-util@2.5.0
├── hexo@5.4.0
├── httpsrv@0.3.2
├── jsdom@17.0.0
├── minimatch@3.0.4
├── nunjucks@3.2.3
└── terser@5.7.2

Your package.json package.json

{
  "name": "maple-blog",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "dev": "hexo s",
    "build": "hexo g && gulp",
    "prod": "hexo g && gulp prod",
    "serve": "httpsrv -i -f 404.html"
  },
  "type": "module",
  "dependencies": {
    "@next-theme/plugins": "^8.7.1",
    "graceful-fs": "^4.2.8",
    "gulp": "^4.0.2",
    "gulp-csso": "^4.0.1",
    "gulp-dom": "^1.0.0",
    "gulp-html-minifier-terser": "^6.0.1",
    "gulp-imagemin": "^8.0.0",
    "gulp-pretty-data": "^0.2.0",
    "gulp-terser": "^2.0.1",
    "gulp-uglify": "^3.0.2",
    "hexo": "^5.4.0",
    "hexo-filter-mathjax": "^0.7.1",
    "hexo-fs": "^3.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^3.0.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-restful": "^0.2.3",
    "hexo-generator-robotstxt": "^0.2.0",
    "hexo-generator-search": "^2.4.3",
    "hexo-generator-sitemap": "^2.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-related-popular-posts": "^5.0.1",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-pandoc": "^0.3.0",
    "hexo-renderer-stylus": "^2.0.1",
    "hexo-server": "^2.0.0",
    "hexo-util": "^2.5.0",
    "jsdom": "^17.0.0",
    "minimatch": "^3.0.4",
    "nunjucks": "^3.2.3",
    "terser": "5.7.2"
  },
  "hexo": {
    "version": "5.4.0"
  },
  "devDependencies": {
    "httpsrv": "^0.3.2"
  },
  "resolutions": {
    "stylus": "^0.54.8"
  }
}

Others

stevenjoezhang commented 3 years ago

See also https://github.com/hexojs/hexo/issues/3245

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stevenjoezhang commented 1 year ago

You can try this plugin: hexo-img-locator

For file structure like this:

_posts/
      |
      - Some-Title/
          |
          - index.md (Markdown file of this post)
          |
          - Assets of Some-Title, e.g. example.png

You can simply use ![](example.png) in index.md