hexo
hexo copied to clipboard
Better asset management
Check List
Please check followings before submitting a new feature request.
- [x] I have already read Docs page
- [x] I have already searched existing issues
Feature Request
If I enabled the post_asset_folder
in _config.yml of HEXO, it will always create a new asset folder after hexo new
but sometimes I just want to create a new post without asset, but the default behaviour will still create a asset blank folder to make my sources dirty and not useful
So I wish to add one more feature to control whether I need the asset folder.
More over I hope that Hexo can impove its default rendering of image reference to support a original markdown syntax
- Add a asset off parameter for the command
hexo new
to controlAssetOff
after enabling asset folder - Improve the asset url management for the natural markdown phrasing
Image reference
Improve the url reference for three scenarios in just one go:
- Markdown preview in local
- Hexo s in local after rendering
- static web page in /public host in the github page


Here is the sample generated by using the asset link
https://leonvision.online/technology/2019/12/16/my-favorite-extensions-for-visual-studio-code/
Asset Link for integration
https://liolok.github.io/zh-CN/How-to-Add-Image-to-Hexo-Blog-Post/
Others
Please describe Improve the url reference for three scenarios in just one go
?
For example, what did you written and where did you placed your image files before, then what happened, and what do you want to write in your markdown file and achieve what then.
Let me guess.
_source/post/
2019-02-14-Test-Post.md
2019-02-14-Test-Post/
+-- Test-Image-1.png
+-- Test-Image-2.png
+-- Subdirectory/
| +-- Test-Image-3.png
| +-- Test-Image-4.png
And the post will be rendered in https://blog.example.com/2019-02-14-Test-Post/
./Test-Image-1.png
and ./Test-Image-2.png
works at post page because they are under same directory with index.html
, but will not work at homepage.
But the problem is your NexT theme (and probably all of the theme) use post.content
. Since every post will be only rendered for once, it is impossible to have different output for post.content
at index and page.content
for the post.
https://github.com/theme-next/hexo-theme-next/blob/master/layout/_macro/post.swig#L205 https://github.com/theme-next/hexo-theme-next/blob/master/layout/_macro/post.swig#L208
I have noticed hexo-renderer-marked
has an option prependRoot
. root
will be prepended after this option is enabled. I am wondered if we could prepend post path as well.
https://github.com/hexojs/hexo-renderer-marked#Options
Please describe
Improve the url reference for three scenarios in just one go
?For example, what did you written and where did you placed your image files before, then what happened, and what do you want to write in your markdown file and achieve what then.
Thanks for your reply, SukkaW.
Normally, we will refer the image in markdown syntax like below:


but we can get the correct rendering result in local preview, but it can not render correctly after in local Hexo server and the same as it after we push it to the host online. I think every markdown syntax should be rendered correctly in three scenarios:
- local markdown preview without hexo server
- local markdown preview with hexo server
- online markdown rendering in host
that could make the writing naturally align the markdown syntax and rendering correctly
See also https://github.com/hexojs/hexo/issues/3245
It can be solved using this third-party plugin: https://www.npmjs.com/package/hexo-img-locator