I am very new to Hugo and could need some help setting up a multilanguage static website.
The website should be simple and straight.
Here is a small overview:
The main navigation will look like this:
HOME | WORK | ABOUT | CONTACT | LANGUAGE_SELECT
About, Contact will be simple single pages.
There will be some more single pages for privacy stuff and imprint (links in footer).
Each single page of the ‘work’ section should contain a dynamic sub menu that include links to the all single pages in the work subfolder, eg gallery1, gallery2, …, gallery5.
I was able to create that dynamic by adding the following code to layouts\work\single.html:
<ul class="list-unstyled">
{{- $firstUrlElement := print "/" (index (split .URL "/") 1) "/" -}}
{{ $url := .URL }}
{{ range where .Site.RegularPages "Section" "work" }} {{ if ne .Title "Pages" }}
<li class="{{ if eq $url .URL }}active{{ end }}">
<a href="{{.RelPermalink}}">{{ .Title | markdownify }}</a>
</li>
{{ end }} {{ end }}
</ul>
The current content folder organization look like this:
Yes, I looked at that section and the sub topic ‘Translate Your Content’. I searched the forum as well but did not found a solution. I will do some more research.
If I click on the ‘WORK’ navigation link which points to http://my-domain/work/ I currently get a default page rendered by layouts_default\list.html.
Is it possible to show the page only if length of .Paginator.Pages <= 0, otherwise show - or redirect to the first page of .Paginator.Pages?
In the common use case do you expect not to have any items in that collection, @vulcan? If not, would adding a single item using some ipsum text suffice during development? If it’s disrupting your dev workflow why not just hide it with CSS and add a TODO item for later? (Sorry if I’m oversimplifying.)
That´s a good point. It´s not expected that there are no items in that collection / section. So it seems that I can ignore that use case.
But how can I show the first item or a specific item of that collection by clicking on the section menu entry?
Clicking on ‘WORK’ or entering http://my-domain/work/ should should navigate to http://my-domain/work/gallery1
An alias cannot be used here, right?
You’re definately on the right track being concerned about the URLs. Best never to change them. Thankfully Hugo gives us a lot of flexibility on how the files are organized without forcing URLs to have to change.
If you’re making a gallery under /work you could create a single page called work in the content directory and pull in a collection of gallery data, give it a layout. In this case the gallery wouldn’t have its own subpath but that’s okay because you won’t ever risk sharing a URL you might get the urge to later break when you reorganize stuff.
Once you have two galleries you’ll probably want both to show up on the work page and, once you reach that point, refactor the content to make the subpaths and use the work page to show a slim view of the detailed gallery views.
There’re other ways to accomplish this as well, some of which would require you to perform redirects on the remote webserver. But for now I’d just go simple until you’re familiar with the content management concepts in Hugo.
Hope that makes sense. Just let it rip and when you hit stumbling blocks try and ask some specific questions here after you struggle for a while to figure it out.
I followed your suggestions as good as I could and I´ve done this:
Created a single page work in content. This single page consumes a ‘work’ partial with the main layout (navigation to select a gallery and the gallery content section, based on Bootstrap tabs). The ‘work’ partial itself consumes a ‘gallery’ partial to fill in the items / thumbnails in the content section.
How do I refactor the content to make the subpaths you mentioned before? Should I post some more source code?