-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Post Asset Folder feature in Hugo #1768
Comments
@NuLL3rr0r: You can have a post asset folder, and I think it'll work if you say From an SEO perspective, you should drop the dates from your URL and redirect, but that's another discussion. |
@derekperkins thank you for the response. Yes, I can create the folder and put my images there. But, it's not quite a post asset folder, at least by what other generators like hexo mean. Just look at the directory hierarchy:
Then I can change my permalinks later in the config file to whatever I want (e.g, include dates or not). In addition to that I ran a quick test with your suggestion. And, let's say I put my pics in a .md file like this:
It won't show the image on the home page (yes, obviously inside that page it does). I believe the generator should handle the urls from home page, too. Because, if I change the permalink, it will break all my posts:
This one is not flexible. |
Fair enough, but I don't think people are changing their permalink structures that often... at least they shouldn't be. Couldn't you create your own shortcode that linked to the current folder? I think there's enough data in the .Node/.Page context, but I'm not sure. Sounds like a good PR. This is somewhat off-topic, but I saw it today and it reminded me of this post. |
Thanks for the info. Actually latest issue of Moz Top 10 had an article on dates in URL which I found interesting, too. The shortcode is a nice idea. Actually, it seems to be the most feasible one at the moment. I'll try to implement a my own shortcode system on a subdomain or a spare domain. Thanks. |
This issue has been automatically marked as stale because it has not been commented on for at least four months. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in four months if no further activity occurs. Thank you for all your contributions. |
Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't. If this is a bug and you can still reproduce this error on the latest If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. |
Trying Hugo once again, and this problem still exists (previously here #1199). Filesystem layout:
Output after running
Does this demonstrate the problem adequately? |
+1 it would be really nice to have a |
I had a similar situation as @gima with blogdown (a wrapper for hugo written in the R language) where I had the following two files
Blogdown and Hugo then created:
It seems like what should happen is for Hugo to copy over I ended up solving this issue by making the following changes in
Now hugo creates:
Which works for me. |
@skadauke You could also put the files in subfolders like this:
Hugo should create the following with
|
Working Now - My observations: I kept trying to adjust the path in the file that would not display the image in various ways including copying and pasting from the one that worked and refreshing the web page. Still not working. But, when I changed text in the page and saved it, the image was rendered. Hope this hint helps. I'll let you know any other nuance I come across on this here as I will be doing quite a bit of rewriting today and exercising the images. Original Post With My Use Case Before Getting It To Work: My Use Case:
The graphics provide a context that keeps being referred to over and over, with the image used on different pages/posts, so a student can form a mental model of the big picture while drilling in and out into the details. Much more reuse than one offs. I need to store my master images in one directory path (which may be organized into subdirectories) and point at them by relative reference from many pages.
This is always needed in any content management. With any site with a lot of content, there will be the need to organize it in different and appropriate ways. And for static site generators this should just work directly. I am surprised it doesn't here given how good Hugo has been to this point. I have been having fun until about 3 hours ago. :) Personally, I have had no success yet with all the combination of solutions offered in the many blog posts related to this problem of "pointing" at an image resource in markdown, and having it render in the localhost:1313 pages. I can see the text description change but never an image to view. This is a fundamental problem. I have been moving assets from my Wordpress site and having a great deal of fun over the last 30+- hours thinking about how great this experience with the JAMStack using Hugo is until the last few hours trying to get this to work. I propose:
and, optionally, "relativeToContent" so a person can choose a location to store their images relative to their content in custom structures (including with the content) (nice to have for me, but rare) in that order.
I do not want extra "copies" of an image automatically placed into a "content" directory associated with a page or post. Let git manage versions. Please no unplanned, or work-around duplicates to manage. I hope this helps. I will continue experimenting, but for now, after reading others comments, I wanted to raise awareness of my experience here today. And thanks to those who work on it. Hugo is great. I want to continue using it if I can overcome this issue. Any additional pointers are appreciated. |
This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I just started migrating my blog from Hexo 3.x (before that Ocropress 2.x that's why I must stay backward compatible, lots of posts and images) and I must say this issue is a huge blocker. At least it has been address by a handful of people #147 #1199 #1122 #1240 but I still see this feature lacking in Hugo as of v0.15. So, I'll explain a bit more:
Hexo has a concept called Post Asset Folder
My Hexo blog has these configurations:
So, from now on when I create a new .md file using Hexo's new command it also create a folder by the same name in the same directory as the .md file:
Then I put any static assets for that post in that folder and it generates the following output in the public folder:
Which makes sense. So, I do not have to create all those blog, 2016, 01 and 11 folders for all those posts I have. Beside the effort, I am sure it is very error-prone. In my estimation that makes life simpler and easier.
Hugo is a solid peace of software which beats every other static-gen out there that I've seen by any measure. It would be great to have a few lines in the config file to enable this necessary feature (could be disabled by default) for people who rely on it even if it does not make sense for its developers.
The text was updated successfully, but these errors were encountered: