Help Site.Data and/or normal content

Hi

Just a quick question for some pointers/help. I’m trying to build a photography portfolio site / blog with an HTML template I bought a few weeks ago. I’m trying to go through the HTML and ‘templatize’ it to fit with Hugo. I would appreciate if you could help me a bit with this by giving me a few tips, as I got stuck.

For the photography portfolio bit, what I’m trying to do is to have on the main page a list of galleries to which I want to link. Each of these galleries are displayed by showing a small photo, a text and the number of photos in the gallery, and possibly some other text. When you click on it, I’d like it to go to a gallery URL like /gallery/london which will show the relevant photos.

I created a proof of concept by leveraging the data directory, so that I go through the $.Site.Data.galleries variable, showing all the data that I have defined in a set YAML files. However I got stuck here. I think I’m not using the right tool with the data directory.

Is the data directory the right way to do this? Or should I treat each of these galleries like the rest of the content for a hugo site, inside the content directory. In that case, could I extend and add more metadata to each content/gallery page that then I can use from the front page?

Otherwise, I don’t really understand what the data directory is used for. What are usual use cases for it?

If this is covered in the documentation and I’ve been thick enough to overlook it (or in this discuss forum), please let me know. Or otherwise, I would really appreciate some pointers about this. :slightly_smiling:

Thank you very much

Could you please give a link to your repository so we can see your code. Thinking for about 30 seconds about it, I think the data directory sounds like the right approach for it.

Possibly relevant for a photo gallery:

Hi Rick,

Thanks for your reply. I don’t have the repository available as this is a paid HTML template (that I am converting to Hugo). I know that once the site is up, someone determined can grab all the pieces and put them together. Anyway, I think the license it has does not allow me to do that.

Would you like me to post some bits of the code and/or the files in data ?

Thank you

Interesting. Let me read about it :slightly_smiling:
thanks

Otherwise, with the data directory, would it be possible to use it to generate both the entries on the front page and each individual HTML page for each gallery?

@golan, well, put a gist up then, I suppose?

As far as I understand it and have been using it, the data directory is a passive thing that is pulled from. Its presence does not trigger any generation. Instead, your templates pull from the data directories.