-
Notifications
You must be signed in to change notification settings - Fork 60
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
Question: How to refresh content/abc/_index.md? #13
Comments
Oh man, I wish there was a way to do this. I looked around the Internet a bit for a hugo feature like that. I don't think there's something built-in right now, and it's not something that'd get added as part of the theme. The problem is - the default.md archetype file has code in it that runs and builds the structure out for any of the photos it finds. (I think that was @githubmonkey's cool feature add - I didn't even realize hugo would run code in there.) But it only runs when you use "hugo new". I don't see anything like "hugo refresh" - but also the way everything is setup right now I can see how that would be really tough to make in a general case. I think the fastest option would be to use "hugo new new_content.md" or something like that to create a new list of all the content again. Then I would dump all that stuff onto the bottom of my _index.md file and delete the parts that I don't want. That goes quickly... But it'd still be tedious once everything turned into a lot of content. Another option I've used for similar problems is to use a database of filename / metadata, then have a separate script scan for the new files and update the database and output the content in the format Hugo needs. Actually - since YAML usually has programming language libraries easily available, it would be easy to use the file itself and the frontmatter as the database. But I'd still have to write a separate script to re-read the directory content and update the stuff in there. Ok - now I'm thinking, there's probably a way I could do this in the general case and produce the output as needed by hugo. Thing is - I'd have to write this as a Python script (or similar). I could do that - but folks would have to have a Python interpreter on their system to use it. I can't think of a way to make this work using like, go templates, or something else Hugo would handle itself. I might do this still. It'd be in Python. It'd be in like a separate "utilities" directory in the theme. Not sure if that's helpful to you and others though. |
Hi ! :-) I wrote a Bash script to handle that in my GitHub Action :
This script will also gather EXIF data from each picture and add this information to the picture description. You can see the result here : MrRaph_ Photo - Gallery Hope it'll help you :-) |
I am thinking an intermediary built using core Python and eliminating external dependancies. Most Linux distributions out there come with some version of Python 3.x pre-packaged so this should work out-of-the-box even in build systems and pipelines. The script runs and generates a JSON file in the Hugo Sample JSON structure{
"name": "gallery",
"type": "folder",
"children": [
{
"name": "album1",
"type": "folder",
"children": [
{
"name": "landscape.jpg",
"type": "file",
"file_md5": "ccddidd",
"title": "This is image title which is not maintained by script",
"description": "This is image title which is not maintained by script"
},
{
"name": "portrait.jpg",
"type": "file",
"file_md5": "bbccdde",
"title": "This is image title which is not maintained by script",
"description": "This is image title which is not maintained by script"
}
]
},
{
"name": "album2",
"type": "folder",
"children": [
{
"name": "vacation.jpg",
"type": "file",
"file_md5": "aabbccc",
"title": "This is image title which is not maintained by script",
"description": "This is image title which is not maintained by script"
}
]
}
]
} We can then edit theme templates to consume the JSON file and build the necessary pages. We don't need to rely on Markdown files in the content directory. We also have the option to create multiple such single file databases, one for each album so that it is easier to tackle raw JSOn when updating image titles and descriptions. Further reading:
Update: You might want to take a look at bep/galleriesdeluxe. The one small issue I have with it is its go dependancy. You cannot use it with standalone |
I have something like this ('content/nature/_index.md'):
If I add further pictures to 'assets/nature/' ... how to refresh _index.md (without loosing the manually added phototitles and descriptions)?
The text was updated successfully, but these errors were encountered: