Nested indexes with index templates

388 views
Skip to first unread message

Clark Bynum

unread,
Feb 19, 2014, 6:24:39 PM2/19/14
to hugo-d...@googlegroups.com
Hello all, I am trying to create a website using Hugo that has a collapsible navigation bar that mimics a structure similar to this:
  • Getting Started
    • Features
    • Console
      • Systems
      • Data
        • Data1
        • Data2
  • Building an App
    • iOS
      • Tutorials
      • Samples
    • Android
      • Tutorials
      • Samples
Is it possible to dynamically generate the sub-directories? Or do I have to hard code for each group? 

I am following this example to render my indexes:
<ul>
    {{ range $indexname, $index := .Site.Indexes }}
      <li><a href="/{{ $indexname | urlize }}">{{ $indexname }}</a> 
        <ul> 
          {{ range $key, $value := $index }}
          <li> {{ $key }} </li>
                <ul>
                {{ range $value.Pages }}
                    <li hugo-nav="{{ .RelPermalink}}"><a href="{{ .Permalink}}"> {{ .LinkTitle }} </a> </li>
                {{ end }}
                </ul>
          {{ end }}
        </ul>
      </li> 
    {{ end }}
  </ul>

Alex Dunn

unread,
Jul 6, 2014, 6:40:03 PM7/6/14
to hugo-d...@googlegroups.com
I've been trying to figure this out too.  Have you had any success?

Steve Francia

unread,
Jul 7, 2014, 11:36:27 AM7/7/14
to hugo-d...@googlegroups.com, Alex Dunn
The Menus feature of Hugo does this easily.

The documentation for it is at http://hugo.spf13.com/extras/menus
The docs site uses it in a similar way as you describe. Check the source there for more information.

--
Hugo
 
A Fast and Flexible Static Site Generator built with love by spf13 and friends in Go
 
Download the latest at https://github.com/spf13/hugo/releases
---
You received this message because you are subscribed to the Google Groups "Hugo Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hugo-discuss...@googlegroups.com.
To post to this group, send email to hugo-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/hugo-discuss.
For more options, visit https://groups.google.com/d/optout.

Alex Dunn

unread,
Jul 7, 2014, 11:40:09 PM7/7/14
to Steve Francia, hugo-d...@googlegroups.com
I may have misread the original question.

My problem is that I want an index.html file for nested groups of content. My /content folder looks like this:

/content
/courses
/spring2014
/people
/faculty
/staff

Hugo generates /courses/index.html and /people/index.html when I add courses.html and people.html to /layouts/indexes, but I can’t get /courses/spring2014/index.html by doing that. (I tried /layouts/indexes/spring2014.html and /layouts/indexes/courses/spring2014.html, of course, but neither worked.)

Alex

———————
Website: http://alexdunn.info
PGP public key: http://pastebin.com/raw.php?i=CgtqpXYt
signature.asc

Steve Francia

unread,
Jul 9, 2014, 10:15:00 AM7/9/14
to Alex Dunn, hugo-d...@googlegroups.com
If I understand correctly Hugo already does this. 

On my blog I have 3 directories inside content, post, presentation & project. Hugo automatically creates an index.html file for each of those directories.


Is that what you mean?

Alex Dunn

unread,
Jul 9, 2014, 7:31:42 PM7/9/14
to Steve Francia, hugo-d...@googlegroups.com
My situation is like if you had directories inside ‘presentation’, like ‘Q1’, ‘Q2’, ‘Q3’, ‘Q4’. I’m trying to generate /presentation/Q1/index.html, /presentation/Q2/index.html, etc., in addition to /presentation/index.html

———————
Website: http://alexdunn.info
PGP public key: http://pastebin.com/raw.php?i=CgtqpXYt

signature.asc

Steve Francia

unread,
Jul 9, 2014, 8:23:33 PM7/9/14
to Alex Dunn, hugo-d...@googlegroups.com
Ahh. Makes sense. Hugo doesn't do this today, but it probably should. 
--

rahul286

unread,
Sep 15, 2014, 3:23:07 AM9/15/14
to hugo-d...@googlegroups.com
I am also looking for a solution/workaround for this.

Posting here to stay in loop.
Reply all
Reply to author
Forward
0 new messages