Custom data attributes act like text attributes for your page or site. You can use them for any number of uses including structuring text content on a faculty profile, adding a class to a <div> that is easily editable by a content author, or for entering a site-wide calendar category. These are just a few examples among many of what you could do with Custom Data for your page or site.

How to use Custom Page Data attributes

We’ll first look at how custom data interacts with pages:

  1. Add a custom_data_attributes entry to the theme config.yml file:

    config.yml Example:

    custom_data_attributes:
     - key_1
     - key_2
     - example_3
     - some_word_4
    

    And/or to one or more template files (eg: frontpage.html or backpage.html). Place the custom_data_attributes below the dashes (---) at the top of the file directly below where the layout is defined:

    Template Example:

    ---
    layout: default
    
    custom_data_attributes:
     - key_1
     - key_2
     - digital_fusion
     - foobar
    ---
    
    <!-- ...template code below here... -->
    

    The attribute keys can be named anything you want and include spaces, but we reccommend avoiding crazy punctuation—treat them more like programming variables.

    Data attributes defined in the config.yml will be available to all pages. Attributes defined in a template will only be available to pages that are assigned that template, in addition to the global attributes defined in config.yml—if any.

  2. Maintain the data via the Custom Data tab on the Page Properties form.
  3. Consume the data via the <r:page:data name="key_1"/> tag within your templates.

    Example:

    <r:page:data name="key_1" />
    

How to use Custom Site Data attributes

Sometimes, you may want page attributes, but you want them to be “global”. This is where Custom Site Data attributes are helpful. They follow most of the same rules as Custom Page Data. The only difference is that they cannot be defined via a template.

  1. Define the values in config.yml.

    config.yml file:

    custom_site_attributes:
      - site_1
      - cal_code
      - special_id
    
  2. Call the Custom Site Data in your template:
    <r:site:data name="site_1" />
    
  3. Once you have the values defined in config.yml, push and sync your theme, then enter the data in Manage > Settings > Data:

    Screenshot of Manage > Settings > Data

Last updated on December 29, 2015.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.