Marketpath CMS Developer Tutorial Series

Custom Site Settings

Last Updated 3/6/2018

We previously discussed some site settings that improve usability on the site. Now we will explore how a developer can define their own custom site settings to improve code re-usability while also simplifying site and page definitions.

Custom site settings are useful for a variety of purposes. Perhaps the most obvious purpose is to define content that is re-used across the site without having to define it on each page individually or hard-code it into the template. This makes it easier for content editors to modify it without requiring excessive edits or touching template code.

One of the major benefits of custom site settings is that they can be exported and imported between sites - making templates easier to port between sites. Instead of hard-coding your site-wide values directly in the template, which would require editing the template on every site you import it into, you define a custom site setting which the template references and which is exported along with the template to be imported. Then on the site that you import the template into, you simply edit the site settings after importing the template and the values are automatically updated for you!

Some simple examples:

  • Google Analytics code. Set once for the entire site and add to every page.
  • Select your site's main and footer menus. This may sound simple, but importing your template into new sites will be one step easier and responsibility for switching out menus can pass from the developer to a content editor.
  • Set up social options, such as a checkbox list to select which social links you want to display on articles.
  • Define social media accounts to pull into the site - such as the twitter or Instagram feed to display on your home page and in your sidebars.

To use site settings:

  1. Define the settings in the management interface (Develop -> Custom Site Settings)
  2. Fill them out in the Site Settings (Site -> Site Settings -> Edit Properties)
  3. Save & Publish
  4. Reference the setting in your template(s) using {{ site.settings['setting-name'] }} or the shortcut {{ site.setting-name }}.

ProTip: Prefix your site settings using a short "unique" abbreviation that makes sense to you in order to decrease the likelihood that someone else imports a custom site setting onto the site with the same name (eg: there may be multiple "show_twitter" settings, but only one "mjbb_show_twitter" setting).

---- End of Lesson ----

Question? Correction?

Let's work together to make our documentation as helpful as possible.

What is your name? 
What is your email address? 
Feedback: