{% if page.comments == true %}
  <section class="post__comments">
    {% if site.repository and site.staticman.branch %}
      {% if site.data.comments[page.slug] %}
        <!-- Start static comments -->
        <div id="comments" class="js-comments">
          <h3 class="tile__header">Comments</h3>
          {% assign comments = site.data.comments[page.slug] | sort %}
          {% for comment in comments %}
            {% assign avatar = comment[1].avatar %}
            {% assign email = comment[1].email %}
            {% assign name = comment[1].name %}
            {% assign url = comment[1].url %}
            {% assign date = comment[1].date %}
            {% assign message = comment[1].message %}
            {% include comment.html index=forloop.index avatar=avatar email=email name=name url=url date=date message=message %}
          {% endfor %}
        </div>
        <!-- End static comments -->
      {% endif %}

      <!-- Start new comment form -->
      <h3 class="tile__header">Leave a Comment</h3>
      <p class="instruct">Your email address will not be published. Required fields are marked <span class="required">*</span></p>
      <form id="comment-form" class="post__comments-form js-form form" method="post" action="https://api.staticman.net/v2/entry/{{site.repository}}/{{site.staticman.branch}}">
        <fieldset>
          <label for="comment-form-message">Comment<small class="required">*</small> <small>(<a href="https://daringfireball.net/projects/markdown/">Markdown</a> is supported)</small></label>
          <textarea type="text" rows="3" id="comment-form-message" name="fields[message]" tabindex="1"></textarea>
          <label for="comment-form-name">Name<small class="required">*</small></label>
          <input type="text" id="comment-form-name" name="fields[name]" tabindex="2" />
        </fieldset>
        <fieldset>
          <label for="comment-form-email">Email address<small class="required">*</small></label>
          <input type="email" id="comment-form-email" name="fields[email]" tabindex="3" />
        </fieldset>
        <fieldset>
          <label for="comment-form-url">Website <small>(optional)</small></label>
          <input type="url" id="comment-form-url" name="fields[url]" tabindex="4"/>
        </fieldset>
        <fieldset class="hidden">
          <input type="hidden" name="options[slug]" value="{{ page.slug }}">
          <input type="hidden" name="fields[hidden]"/>
        </fieldset>
        <!-- Start comment form alert messaging -->
        <p class="hidden js-notice">
          <span class="js-notice-text"></span>
        </p>
        <!-- End comment form alert messaging -->
        <fieldset>
          <button type="submit" id="comment-form-submit" tabindex="5" class="btn btn--large">Submit Comment</button>
        </fieldset>
      </form>
      <!-- End new comment form -->
    {% endif %}
  </section>
{% endif %}