TTWeb Basics 4. Content Settings

Content settings are basically models with a single instance. They’re useful for static content that doesn’t get translated (e.g. phone numbers and email addresses) or for things like third-party IDs or library versions.

Content settings files are stored in _data/ in the jekyll project and may either be .yml or .json files. The files will be user-editable via the CMS if a interface definition is provided. To provide an interface for the data, use a key named __EDITABLE_FIELDS__ with the contents of a standard model definition (see Content Model Definitions )

For example, a settings file named analytics.yml might look like:

google_enabled: true
google_id: ABC123
provider_xyz_enabled: false
provider_xyz_id:
uneditable_value: ABC123
__EDITABLE_FIELDS__:
  google_enabled:
    type: boolean
    label: Use Google Analytics?
  google_id:
    type: string
    label: Google Analytics ID
  provider_xyz_enabled:
    type: boolean
    label: Use Provider XYZ Analytics?
  provider_xyz_id:
    type: string
    label: Provider XYZ ID

You may also store key-value pairs that are not user-editable if you provided an __EDITABLE_FIELDS__ definition but don’t specify the addition key names. In the example above the field ‘uneditable_value’ won’t be editable by the user in the CMS because it is not specified by the definition in __EDITABLE_FIELDS__. This field will only be editable via github or in local dev.

Making settings live-editable

If you want to display the content from the setting and make it editable, you can wrap it with a span with data-elements. For example

<footer>
  <div class='email'>
    <span 
        data-live-edit-settings='hotel_settings'
        data-live-edit-settings-field='email'
    ></span>
  </div>
</footer>

This will make that span look like an editable region when a user turns live-edit on. Changes they make will be stored in the file _data/hotel_settings.yml in the field email