Core Themes: Bartik
FreeBartik is a core theme in Drupal. As a default theme for Drupal, it serves as an instructive example of a well-developed responsive theme. In this tutorial, we'll tour and explore Bartik, identify its primary features, and explain the use case for the Bartik theme and what you can learn from it.
Build Drupal Sites
GuideIn this exercise, we'll practice theming by overriding the main menu template. We'll:
- Override and rename the main menu template so that it will only affect the main menu component of our Drupal site.
- Add Bootstrap classes from the base nav component into our overridden main menu template file.
- Add CSS classes to HTML selectors using
attributes.addClass()
andset
methods.
We recommend that you work on the exercise steps below first. You can refer to the video if you need some help.
Develop Drupal Sites
GuideWhat Is a Theme?
FreeThemes are the part of Drupal that you, and anyone else visiting your Drupal powered application, see when they view any page in their browser. You can think of a theme as a layer, kind of like a screen, that exists between your Drupal content and the users of your site. Whenever a page is requested Drupal does the work of assembling the content to display into structured data which is then handed off to the presentation layer to determine how to visually represent the data provided.
Drupal themes are created by front-end developer. Frequently referred to as themers, or theme developers. Themes consist of standard web assets like CSS, JavaScript, and images, combined with Drupal-specific templates for generating HTML markup, and YAML files for telling Drupal about the file and features that make up each individual theme.
In this tutorial we'll:
- Explain what a Drupal theme is.
- Explain the role of a Drupal themer in the process of building a Drupal site.
- Get a high level overview of the types of files/code that themes are made of.
By the end of this tutorial you should be able to explain what a Drupal theme is, and the kind of work a Drupal theme developer will be expected to do.
Introduction to Drupal
GuideWhen it's time to start a custom Drupal theme from scratch (especially if you're new to Drupal theming), we recommend using Starterkit. Starterkit helps you get a new theme up and running by scaffolding a set of theme files with sensible defaults, saving you from a bunch of repetitive work.
In this tutorial we'll:
- Learn what Starterkit is
- Discuss when you should--and should not--use Starterkit
- Walk through how to use Starterkit to generate a new Drupal theme
By the end of this tutorial you should be able to explain the use case for Starterkit and understand how to use it to start a new custom theme.
We recommend planning ahead when using Layout Builder, documenting how you intend to use Layout Builder for your specific use-case, and then doing your best to stick to it. One approach that we've found works well for sites that need a maximum amount of flexibility (and have the resources to do the upfront planning and theming required) is using entity view modes.
This approach is similar in concept to component based design systems, where you do the initial work of creating a set of components that all work well together up-front, and then allow them to be mixed and matched in whatever way is necessary.
In this tutorial we'll:
- Create new view modes for the Basic Page content type representing the different components.
- Use the ctools blocks module to allow displaying an entity as a block and choosing which view mode to use when rendering the entity.
- Provide custom HTML and CSS styling for the new components.
By the end of this tutorial you'll know how to use Layout Builder in combination with entity view modes.
Develop Forms in Drupal
GuideOverview of regions from a theming perspective.
Layout Builder in Drupal
CourseLearn to Theme with Hands-On Exercises
Blog postBased on our popular Drupal 8 Theming Workshop, our new guide, Hands-On Theming (https://drupalize.me/guide/hands-on-theming), is a 7-week course of tutorials and hands-on exercises that will get you up and running with your first Drupal 8 theme. Each week contains tutorials surrounding a key concept in Drupal 8 theming. At the end of each week, you'll have an opportunity to put into practice what you've learned in the related tutorials with a hands-on exercise. By the end of this course, you'll have a working Drupal 8 theme ready for you to further explore and learn concepts in Drupal 8 theming.
To facilitate hands-on practice, we've partnered with Stack Starter (https://stackstarter.io/). To follow along with the steps in each exercise, you can use a customized Stack Starter web-based environment. You'll get a pre-configured Drupal 8 development site ready to start theming. It also includes a web-based file manager and code editor as well as a console where you can run Drush commands.
Drupalize.Me Goes to Washington
Blog postIf you’re headed to GovCon and want to learn some awesome Drupal 8 theming, sign up for our all-day workshop.
Release Day: Theme Hook Suggestions
Blog postWe just added 2 new tutorials about Theme Hook Suggestions! First learn the concept behind this topic in our tutorial Discover Existing Theme Hook Suggestions. Then learn how to add them in our tutorial Add New Theme Hook Suggestions.
No time to learn? What if it was a scheduled event like a workshop? Scheduled professional development events like workshops and conferences can help you get started on a new path. We have 2 theming workshops coming up in February and March for folks ready to learn Drupal’s theming system.
DrupalCon Nashville is right around the corner and we're stoked to not only be attending DrupalCon, but to also be providing our Drupal 8 Theming workshop once again.