title: Accessing an array with a variable in Jekyll/Liquid templating
body: <p>I have the following code in my template:</p>
  
  <pre><code>  {% for post in site.posts %}
      {% capture num_colors %}{{ site.colors | size }}{% endcapture %}
      {% capture color_index %}{{ forloop.index0 | mod: num_colors }}{% endcapture %}
  
      &lt;a href="{{ post.url }}" class="post-box" rel="bookmark" title="{{ post.title }}"&gt;
        &lt;div class="post-block {{ site.colors[color_index] }}"&gt;
          &lt;div class="contents"&gt;
            &lt;div class="cat-tag"&gt;
              {{ post.categories[0] | upcase }}
            &lt;/div&gt;
  
            &lt;h2&gt;{{ post.title }}&lt;/h2&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/a&gt;
    {% endfor %}
  </code></pre>
  
  <p>This keeps returning nothing: <code>{{ site.colors[color_index] }}</code> even though <code>num_colors</code>, <code>color_index</code>, and <code>site.colors</code> will all return the correct things when I try and print them.</p>
  
  <p>colors is defined  in my _config.yml as:</p>
  
  <p><code>colors: [light_blue, coral, yellow, teal, blue, deep_blue]</code></p>
  
  <p>I'm using a plugin to get modulus.  Basically I just want to attach a class for each post that will start over when its gone beyond the total number of colors. This seems straightforward so I'm confused.</p>