5.7 Theme Best Practices (and what makes a good theme)

Permalink 2 users found helpful
I am interested in getting opinions on what people think makes a good theme and potentially establishing best practices once developer documentation is released. With new features like theme presets, it opens the door to making very versatile and customizable themes. Better themes attract more people to concrete5 and provide more value to paid themes.

It would be good to get opinions from developers, designers, tech savvy users, and non-technical users.

A few things I've come up with so far.

1. full marketplace description (in addition to the basic requirements)
- browser version compatibility
- if using a framework, the name of the framework

2. well documented
- instructions for using anything custom (blocks, templates, areas, presets, etc.)
- assume that your end user has no prior knowledge of web technology or web tools beyond using a web browser (this should help reduce support ticket requests)

3. a variety of:
- page types
- page templates
- area classes
- block classes
- block templates
- custom Redactor styles
- theme presets
- style variables
- custom blocks (optional)

4. registration of all assets

5. prevent theme CSS from overriding core styles
- use appropriate CSS selector specificity (overly broad selectors risk overriding core styles)
- avoid using core selectors unless you have a specific reason to
- scope your CSS (.ccm-page is often used as a scope class)

Links to information on CSS selector specificity.

JohntheFish wrote an excellent how-to on scoping theme CSS with a CSS preprocessor.

Here is a neat tool for analyzing the specificity of your styles.

Sass and Less

The theme presets are written in a CSS Preprocessor called Less. Less allows for creating variables needed for all the different dynamic preset properties.

In case you don't know what theme presets are, please check them out.

For those who use Sass, Sass files can be manually and automatically converted to Less. Be warned in advance that Less supports a few things that Sass does not and Sass supports a lot of things that Less does not. You will need to take this into consideration when writing your Sass if you intend to convert.

Some Sass users are using grid systems and sass features that cannot be converted to Less. In these situations, another possibility is using Sass @import to separate your files. You would create a file(s) with all the settings that would be available in a theme preset - fonts, typography styles, background, etc. These theme preset specific files could be converted to Less. Your non-theme preset specific files (like your grid), which do not require Less variables, could be compiled and put into a Less file.

Automated conversion using a grunt task:
- this looks like it does a good job of converting plain Sass files

A few articles about manually converting Sass to Less:

Area naming conventions
- to be determined

Olsgreen made a theme boilerplate that includes all the basics to start making a theme. He also made a screencast tutorial on how to use it.

View Replies:
pedroserapio replied on at Permalink Reply
For me I hope we can see a well document explanation about Folder structure, what files are necessary to create the Base of new Theme. And the name of folders and files must be well explained because I found that some file names give indications to Concrete5 core to read the content in certain way.

Theme presets it's very important, more complete, more easy to us or our clients to give some personalization. Maybe one day Concrete5 have the same capacity of Editing the CSS files directly, like Jo***.
bhat replied on at Permalink Reply
Relating to folder or file structure here are some suggestions.

First lets define basic structure. The ThemeName is required as the initial folder. That folder will be called the root directory or folder if you prefer. Subdirectories will have names like css, images, and js.

Specific names are your preference. Styles or css are common folder names in themes. What is important is that a subdirectory contains the appropriate css or script files.

This is one one suggestion for the files in the root folder:

full.php (even if it is the same code as default.php there should be one additional template file)

It's really that simple.

The subdirectories or folders are simple too:

elements (which is a C5 standard)

Since vendor tools, SASS or LESS and frameworks have their own folder standards you would follow their standards and just integrate those into your theme. Concrete5 appears to support LESS so maybe we should include that in best practices. Please comment on that particular exception.


The file page_theme.php is a major file. Maybe it should be added to Item 3 in the discussion. The class PageTheme and method registerAssets() is extremely important if not essential. The Urbanic tutorial has a great example of how Concrete core assets can conflict with your theme assets. That should be enough to place page_theme.php as an essential part of every theme. Of course, there are other methods that are important to your theme so let's consider discussing this file under best practices.


Finally, C5 core css and your theme css is integrated. After converting a theme from a previous version their css stepped all over the Concrete5 admin toolbar and the admin dropdown sidebars. With this integrated css it is necessary to define elements specifically to classes and id's. This is not just an issue between C5 core and your theme but other third party applications and tools. Should the best practices discussion include a section on coding standards?
MrKDilkington replied on at Permalink Reply
"Since vendor tools, SASS or LESS and frameworks have their own folder standards you would follow their standards and just integrate those into your theme. Concrete5 appears to support LESS so maybe we should include that in best practices. Please comment on that particular exception."

What makes Sass and Less flexible is they don't have folder standards. You can structure your files and folders however you like. This has allowed for a variety of approaches to writing and organizing CSS (i.e. BEM, OOCSS, and SMACSS).

The reason why I bring up converting partial and full Sass files is for using Sass specific tools. An example is the Susy grid system. Susy uses a lot of math functions and control structures not available in Less.