Table of Contents

  1. Data from CSV
    1. Prerequisites
    2. Basic Usage
    3. Example Output
    4. Using Multiple CSV Files
      1. Output from another_data.csv
    5. Table with no header
      1. Output from no_header_data.csv

Data from CSV

You can create tables from CSV files stored in the _data folder of your just-the-docs site.

Prerequisites

First, create a CSV file in the _data folder. For example, create _data/csv_data.csv with your tabular data.

Basic Usage

To render a table from your CSV file:

First, you will need to assign the CSV data to a variable. The Replace the site.data.csv_data with the name of your CSV file (without the .csv extension):

{% assign csv_data = site.data.csv_data %}

Then, create the table structure:

<table>
  <thead>
    <tr>
      {% for header in csv_data.first %}
        <th>{{ header[0] }}</th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
    {% for row in csv_data %}
      <tr>
        {% for cell in row %}
          <td>{{ cell[1] }}</td>
        {% endfor %}
      </tr>
    {% endfor %}
  </tbody>
</table>

Example Output

column1column2empty columncolumn4
hellolinkhttps://mdl.library.utoronto.ca/
23()

Using Multiple CSV Files

To use a different CSV file (e.g., _data/another_data.csv), simply change the file name in the assign statement:

{% assign another_data = site.data.another_data %}

<table>
  <thead>
    <tr>
      {% for header in another_data.first %}
        <th>{{ header[0] }}</th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
    {% for row in another_data %}
      <tr>
        {% for cell in row %}
          <td>{{ cell[1] }}</td>
        {% endfor %}
      </tr>
    {% endfor %}
  </tbody>
</table>

Output from another_data.csv

another_data_column1another_data_column2
hello
data2

Table with no header

If your CSV file does not have a header row, you can skip the header section in the table:

<table>
  <tbody>
    {% for row in csv_data %}
      <tr>
        {% for cell in row %}
          <td>{{ cell[1] }}</td>
        {% endfor %}
      </tr>
    {% endfor %}
  </tbody>
</table>

Output from no_header_data.csv

hellolinkhttps://mdl.library.utoronto.ca/
23()

First created: June 10, 2024
Last updated: December 12, 2025

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International icon