-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Comments
You can try this plugin: hexo-img-locator In new_post_name: :title/index.md
post_asset_folder: false For file structure like this:
You can simply use In fact, I believe this is simpler and more straightforward than the current asset management approach. Perhaps we should consider modifying the default behavior of asset management. What do you think? cc @hexojs/core |
We could make it the new default behavior, and also support the old post asset folder structure (for backward compatibility) |
@stevenjoezhang Thanks for this plugin, but it doesn't work for me. In my case, the image's path was successfully changed but the target path didn't exist:
Another troublesome issue is that the permanent link of the article becomes
While the original permanent link (without ' |
@fuyufjh Yes, the situation is more complicated than I thought. The PostAssets in Hexo need to be updated because currently these images are not recognized by Hexo and copied to the new location. |
I think this is a good approach. It can solve the conflict relative paths between editing and deployment. |
我认为上面这种结构不是问题。问题是在
总之我觉得上面这两种文件的组织方式,可能各有所爱。我还是觉得上面一种文件的组织方式要好一点(可能更方便一些有图床的同学)。 我想到了一个简单解决办法可以将第一种文件组织方式。简单的渲染或生成为下面这种结构应该就可以解决问题了
|
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
):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 NOTpublic
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:
Current Hexo post dir structure:
If we can make it the same, I mean, the path in
source
dir will be the same inpublic
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:
I have tried change config to do this. First I set my config like this:
But it causes this:
And then I changed this:
It ignored asset file like this:
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:
And get a structure like:
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.
The text was updated successfully, but these errors were encountered: