I am playing around Hugo the past couple of days, and slowly picking up things as I play around with it and
watch the free tutorial series.
I am playing around with the Hugo-Initio Theme , however it seems the official creators are inactive on Github so I need to ask here.
I can’t seem to figure out how to have the recentworks layout (img thubnails) and apply it to the
BLOG contents. I don’t want to apply that layout to all types of contents , but just those that fall under BLOG. Currently the way blogs are layed out is just one after another with text.
I would like to see the recentworks layout instad.
How familiar are you with HTML and template coding? What you’re wanting to do doesn’t require advanced programming skills, but you’ll need to know a little.
What you’ll want to do is look at how the ‘recent works’ is built
and then look at how the blog listing is currently built
and either modify _default/list.html based on partials/recentworks.html or if you only want this tiled layout for a certain section of your site, you’ll need to create a seperate layout template there (e.g. layouts/blog/list.html)
Thank you for this! I know the basics of html from webscraping. I just didn’t know where to look.
I will play around with it for the next couple of hours and see if I run into any problems.
Hi funkydan2, I am running into a problem.
Despite using the same html from recent works, I am getting a different display:
## Recent Works
[ See details → Computer Vision ](http://localhost:1313/projects/www.google.com)[Web design](http://localhost:1313/projects/#) | [Wordpress](http://localhost:1313/projects/#) | [Logotype](http://localhost:1313/projects/#)
[ See details → Pure ipsum - development services for people ](http://localhost:1313/projects/#)[Web design](http://localhost:1313/projects/#) | [Wordpress](http://localhost:1313/projects/#)
[ See details → Lorem studios - interior and patio design ](http://localhost:1313/projects/#)[Web design](http://localhost:1313/projects/#) | [Logotype](http://localhost:1313/projects/#)
[ See details → Pure ipsum - development services for people ](http://localhost:1313/projects/#)[Web design](http://localhost:1313/projects/#) | [Wordpress](http://localhost:1313/projects/#)
[ See details → Lorem studios - interior and patio design ](http://localhost:1313/projects/#)[Web design](http://localhost:1313/projects/#) | [Logotype](http://localhost:1313/projects/#)
[ See details → Lorem studios - interior and patio design ](http://localhost:1313/projects/#)[Web design](http://localhost:1313/projects/#) | [Logotype](http://localhost:1313/projects/#)
So to do this you’re going to have to get deep into the Hugo Docs, and especially the area to do with templating, functions, and variables.
The recentworks partial in the theme ranges over data stored in a JSON file. That’s not going to be what you want to do for your blog. For that you’ll want to range range through a paginator.
So, I’d be looking at the logic of _default/list.html (the things in curly brackets) and the layout of partials/recentworks.html (the HTML and CSS).
I am trying to save the current page from the range iteration to $page and then extract the pagenumber which I will use to match the id of recent works.
But it seems my attempt is incorrect.
create a data file (in JSON format) holding your BLOG posts which you want displayed on the home page in a similar manner to Recent Works, or
store your blog posts as markdown files in the content/blog directory, and have the list of blog posts displayed in as tiled images (like Recent Works) rather than a long list as the theme currently does?
Hi Funkydan2,
I am going for number 2. The tab I want to display using recentworks layout is called, “Projects.”
I created a list.html within a Projects folder that I created within layout.
So the Projects folder within layouts has a list.html, which should specify the “Projects” page layout.
I copied the html code from recentworks and tried to modify it so that the Projects page will have tiles display. Since recentworks put it’s data within a json file, I did the same and created a new file called projects.json within data, and thought that I would need to update projects.json with new tiles as I add more blogs/content to Projects
If so, I don’t think you need to double handle things with blog posts (markdown files with front matter) as well as data files. All you need is the markdown + front matter.
In layouts/projects/list.html you’ll want code that uses the logic of the current layouts/_default/list.html (so, ranging through the pages of the paginator) and the html/css of layouts/partials/recentworks.html.
In your layouts/projects/list.html you’ll need something like this:
Completely untested…have a look at the default list.html to work out what needs to go before and after this code to make it work (this will replace something like lines 9-21 of the default/list.html)…but it’s the basic idea.
How it works is that it uses .Paginator to go through your blog files in date order. It then takes the .Permalink value for each page and the Pages .Title and .image (all of which need to be set in each page’s frontmatter) to build the ‘tiles’ of the index page.
Hopefully, this points you in the right direction.
Okay got it working:
I added Image variable in front matter of .md, and then accessed it via .Params.image in the range loop of Projects/list.html
Thank you so much.
UPDATE:
So it seems the layout is a little different for some reason.
Recent works is aligned left to right in rows, while my version seems to be aligned top to bottom.
Is it something with the variable $area?
{{ range $index, $area := .Site.Data.recentworks }}
Glad to hear I pointed you in the right direction.
Could you share your code - either do a bunch of copy and pastes…or best, create a Git repository and share a link
Either you’ve changed the original layouts/partials/recentworks.html and you just need to re-download the original, or you’ve done something to the CSS which has changed the layout.
Hi funkydan.
Ashamedly, I am not very good with git, so I had to watch a few video and learn the basics.
It’s pretty cool everything can be done from the command line
So your layouts/projects/list.html isn’t finished.
The way I learnt to use hugo was by doing exactly what you’re doing - look at someone’s theme and work out why it works, and how to make it do what you want.
So what you need to do is look more closely at layouts/_default/list.html
You need to make your layouts/projects/list.html look more like the default - so for starters, load the header partial at the start and the footer partial at the end, and there’s probably some other HTML you’ll need to write to get things laid out how you want.
Interesting. This is my first time building a website ( the only programming I know is related to Computer Vision and Python). I don’t think I want to do it professionally as it seems stressful, but It’s a pretty cool skill to have and want to try building a few.
Thank you. I will take a closer look at this and play around with it a bit more. I had to finish up some other work, so I’m sorry for the late reply.
I’m no CSS expert, and it’s a bit tricky without seeing all the code. Could you share your code to a git repository, then maybe someone can clone it and see what the relevant part of the CSS is?
(This is most likely a CSS/HTML thing, and so a little outside the scope of the Hugo forums…on the other hand, it’s a helpful community!)
Oops - I forgot that you’d linked to that earlier.
Could you push your latest updates, because at the very least the projects layout is still broken…there’s nothing in their to load the CSS or scripts. It most likely needs to start with {{ partial "header.html" }}.