Skip to content

Create a Template

Before we can create a data collection campaign, we need to create a template.

A template is a blueprint for the tasks in a campaign. It defines the structure of the tasks, the input and output data. Templates are created by the data requester (you) and can be reused across multiple campaigns.

A typical template will be a HTML file that contains the structure of the tasks. The template can contain placeholders for the input data, output data, and other dynamic content. In this case, we aim to determine whether an image depicts a Chihuahua or a muffin. Our template should include the following:

  • Load an Image: In order for our workers to distinguish between a Chihuahua or a Muffin, an image must be loaded and displayed to them.
  • HTML Form: We must integrate an HTML form into the template so our users can fill in whether the loaded image is a Chihuahua or a Muffin.
<html>
  <head>
    <title>Chihuahua or Muffin</title>
  </head>
  <body>
    <form>
        <div class="classify-image">
            <h1 class="title">Chihuahua or Muffin ?</h1>
              <!-- The image loaded from IPFS using a template variable -->
            <img src='https://gateway.pinata.cloud/ipfs/${ipfs_url}'/>
        </div>
        <div class="question question-sentiment">
              <!-- Our question to ask the workers-->
            <h2 class="subtitle">Is this an image of a Chihuahua or a Muffin?</h2>
 
              <!-- Input options for the workers-->
            <div class="field">
                <input class="is-checkradio" id="chihuahua" value="chihuahua" type="radio" name="resemblance" required>
                <label for="full">Chihuahua</label>
                <input class="is-checkradio" id="muffin" value="muffin" type="radio" name="resemblance">
                <label for="half">Muffin</label>
            </div>
        </div>
 
        <!-- Submit button so workers can submit their data -->
        <button type="submit" class="is-large mt-6">Submit</button>
      </form>
  </body>
</html>

In the above template, we are making use of a placeholder ${ipfs_url} This value will be filled with our images when we create the tasks.

You can find examples for different types of templates on our github We highly recommended to follow the template guide when you are creating your own template.

Now that we have created a template for our campaign, we can move on to the next step: Creating a Campaign