title: shell script to create a static HTML directory listing
body: <p>So I'm creating a GitHub Pages site to list all of the Gifs in my <a href="https://github.com/jglovier/gifs" rel="noreferrer">jglovier/gifs</a> repo. GH Pages runs only static HTML/CSS/JS or Jekyll, so I cannot use an apache directory listing or any other server generated variant.</p>
  
  <p>So what I'd like to do is run a script on the command line and have it browse the root for directories, list all the files inside (which only go one level deep), and output that to an html <code>ul &gt; li &gt; a</code> structure, or something similar to this:</p>
  
  <pre><code>root/
  |
  ├── accidents/
  |   ├── accident2.gif
  |   ├── accident3.gif
  |   └── accident4.gif
  ├── bears/
  |   ├── bears1.gif
  |   ├── bears2.gif
  |   └── bears3.gif
  └── cats/
      ├── cat1.gif
      ├── cat2.gif
      └── cat3.gif
  </code></pre>
  
  <p>I'd like the href values to be site-root relative paths (i.e. <code>href="/cats/cat</code>.gif<code>), and I need it to output into</code>_includes/site-index.html<code>, which will get pulled into a Jekyll layout file that wraps around my</code>index.md<code>file and generates</code>index.html` on build.</p>
  
  <p>I <a href="https://stackoverflow.com/questions/20275254/bash-script-to-create-a-html-nav-menu">found this other question</a> which is very similar, and tried to implement it's answer for my purposes, but alas I'm too much of a shell n00b to accomplish it on my own.</p>