LogoLogo
9.0.x
9.0.x
  • Overview
    • About Varbase
    • Roadmap
    • Release Cycle and Supported Versions
    • How to Get Support
  • Developers
    • Getting Started
    • Installing Varbase
      • Requirements
      • Installing Varbase with DDEV
      • Installing Varbase with Lando
    • Understanding Varbase
      • Basic Concepts
      • Core Components
        • Varbase Core
          • Varbase Admin
          • Varbase Page
          • Varbase Security
          • Varbase Webform
          • Varbase Default Content
          • Varbase Tour
        • Varbase Media
        • Varbase Editor
        • Varbase Email
        • Varbase SEO
        • Varbase Workflow
        • Varbase Layout Builder
          • Varbase Landing page (Layout Builder)
          • Varbase Heading Block
          • Varbase Rich Text Block
          • Varbase HTML Code Block
          • Varbase Media (Image/Video) Block
          • Varbase Gallery Block
        • Varbase Total Control Dashboard
        • Vartheme Claro
        • Vartheme BS4
      • Optional Components
        • Varbase API
        • Varbase Internationalization
        • Varbase Media Hero Slider
        • Varbase Carousels
        • Varbase Blog
        • Varbase Search
        • Varbase Social Single Sign-On
        • Varbase Media Twitter
        • Varbase Media Instagram
        • Varbase Content Planner
        • Varbase Bootstrap Paragraphs
          • Varbase Bootstrap Paragraphs Text and Image
        • Varbase Landing Page (Paragraphs)
      • Additional Components
        • Varbase Media Header
        • Varbase FAQs
        • Varbase Reports
        • Varbase Commerce
        • Varbase YouTube Import
      • Development Components
        • Varbase Development
        • Varbase Style Guide
        • Reroute Email
        • Varbase Updates Helper
    • Configuring a Varbase Site
      • Navigation
        • Defining Active Menu Trail Using Menu Position
      • Using View Modes Inventory
      • Content Moderation and Workflows
      • URL Aliases in Varbase/Drupal
        • Configuring URL Aliases
        • Managing URL Aliases
      • Managing URL Patterns for Multilingual Websites
      • Managing Date and Time Formats to Display Across the Site
      • Using Varbase Layout Builder
        • Creating a Landing Page With Varbase Layout Builder
        • Activating Varbase Layout Builder for Content Types
      • Configuring Pathologic When Going Live
      • Configuring SEO Features
        • Disallow Oembed Media Links
      • Configuring Security Features
        • Spam Protection
        • Password Policies
        • Other Security Kits
        • Flood Contorl
        • Enable HTTP Password Authentication
      • Configuring JSON:API Features
      • Configure Varbase Media Hero Slider
      • Configuring Varbase Media Header
      • Configuring Varbase Mailer Settings
        • Configure Symfony Mailer
        • Configure Swift Mailer
        • Switch From Swift Mailer to Symfony Mailer
      • Entity Definition Update Manager Class
      • Module Installer Factory Class
    • Theme Development with Varbase
      • Understanding The Vartheme Base Theme
      • Creating Your Own Theme
      • Local Tasks and Moderation Sidebar
      • Add Preloaded Fonts in Vartheme
      • Switch From Node SASS to Dart SASS for Old Sub-Themes
    • Launching a Varbase Site to Production
    • Updating a Varbase Site
      • Understanding Varbase Updater Package
      • Handling Patches When Updating
      • Handling Configuration Updates
      • Updating Varbase to work with Composer 2.0
      • Updating Drush to the Latest Stable Version
      • Version Update Guides
        • Updating Varbase ~9.0 to Drupal 10
        • Switch from CKEditor 4 to CKEditor 5 in Varbase ~9.1.0
        • Updating from Varbase 8.x to 9.x
    • Varbase Patches
    • Frequently Asked Questions (FAQs)
    • Extending Varbase
      • Overriding Varbase
      • Creating Your Own Feature
      • Creating A Sub Profile From Varbase
        • Varbase Sub Profile Generator
        • Varbase Sub Profile Basic Template
        • Varbase Sub Profile Basic Project Template
      • Install Needed YARN and Gulp Tools
      • Compiling Provided Component Styles
      • Check Standards/Practice Coding And Linting
  • Content Designers
    • Terminology
    • Accessing the Administration Area
      • Website Environments
    • User Management
      • Allow Email/Username Login & Registration
      • Default Roles and Site Personas
        • Edit Roles' Permissions
        • Managing Roles
      • Add User
      • Edit User
      • Masquerading as another user
    • Dashboard
      • Reports
    • Content Structure
      • EntityQueues
      • Menu Management
        • Add Menu Items
        • Update Menu Items
        • Adding a Page to the Menu
      • Taxonomies
        • Manage Vocabulary
        • Edit Vocabulary
        • List Terms
        • Add Terms
        • Reorder and Edit Terms
      • Webforms
        • Setting up Emails Handler Conditions
        • Setting up Confirmations Message Settings Types
    • Content Management
      • Create Content
        • Add a Basic page
        • Add a Landing page
        • Add Blog
        • Add Media
          • Image
          • Remote video
          • Video
      • Modify Content
      • Delete Content
      • Preview Content
      • Bulk Edit Content
      • Content Moderation
      • Publish Content
      • URL Alias
    • About Layout Builder
      • Section
      • Custom Blocks
        • Heading Block
        • Basic Block
        • Media Block(Image/Video)
        • Rich-Text Editor “WYSIWYG”
      • Managing Blocks
    • Search Engine Optimization
      • XML Sitemap
      • Meta Tags in Varbase
      • URL Redirects
      • Domain Redirects
      • Prevent a Single Content From Being Indexed
    • Site Configuration
      • System
        • Clearing Varbase Cache
        • Google analytics
        • Mail templates
      • User interface
      • Development
      • Varbase settings
      • Web services
    • Common Error Handling Tips
  • Contributing
    • Contributing to Documentation
Powered by GitBook
On this page
  • Install Needed Tools Command
  • Install Needed Tools Manually
  • 1. Install sed and gawk
  • 2. Install npm and nodejs
  • 3. Install Yarn
  • 4. Install Gulp
  • Create new Vartheme BS4 Sub Theme
  • Create with Bash Script
  • Create with Yarn
  • Example mythem for mysite
  • Activate the New Theme
  • Initiation Commands
  • Compiling SCSS to CSS
  • Watching SCSS Changes
  • Cloning a Project
  1. Developers
  2. Theme Development with Varbase

Creating Your Own Theme

PreviousUnderstanding The Vartheme Base ThemeNextLocal Tasks and Moderation Sidebar

Last updated 1 year ago

After building and installing the project with the template, use the create new Vartheme sub theme command.

Before that have a look at:

Learn more about Bootstrap standard build tools documentation, compile source code, run tests, and more.

Install Needed Tools Command

  1. Open a terminal window.

  2. Change directory in the terminal to docroot/themes/contrib/vartheme_bs4/scripts in the project.

  3. Run the bash ./install-needed-tools.sh

  4. Follow with the list of instructions.

cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs4/scripts
bash ./install-needed-tools.sh

Install Needed Tools Manually

Recommended doing the installation of needed tools using the bash script command. But if that is not the case. By deciding to manually install custom versions. Please follow with the following steps.

1. Install and

Helps with string replace and re-naming files.

sudo apt install -y sed gawk;

Helps getting more development tools and the Bootstrap and popper packages.

curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - 
sudo apt update
sudo apt install nodejs
sudo apt install build-essential

curl -L https://npmjs.com/install.sh | sudo -E bash -
sudo apt update
sudo apt install npm
sudo apt install yarn

Install Yarn as a global by npm

sudo npm install -g yarn

Helps in managing tasks when compiling SASS/SCSS to CSS

sudo npm install gulp-cli -g
sudo npm install gulp -D

Create new Vartheme BS4 Sub Theme

Create with Bash Script

  1. Open a terminal to run commands

  2. Change directory in the terminal to docroot/themes/contrib/vartheme_bs4/scripts

  3. Run the create-new-vartheme-bs4.sh "THEME_NAME". Change the THEME_NAME to the project name or any selected theme name.

cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs4/scripts
bash ./create-new-vartheme-bs4.sh "THEME_NAME"

Create with Yarn

cd PROJECT_DIR_NAME/docroot/themes/contrib/vartheme_bs4
yarn theme:create-sub-theme "THEME_NAME"

Example mythem for mysite

If a Varbase site named "mysite" was built using the following command:

cd /var/www/html
composer create-project Vardot/varbase-project:~9 mysite --no-dev --no-interaction

The folder mysite for the project is located at "/var/www/html/mysite"

Change directory to docroot/themes/contrib/vartheme_bs4/scripts

cd /var/www/html/mysite/docroot/themes/contrib/vartheme_bs4/scripts

Run the following bashcommand to create a custom theme named "mytheme"

bash ./create-new-vartheme-bs4.sh "mytheme"

The new theme will be located at "/var/www/html/mysite/docroot/themes/custom/mytheme"

When the finishes the following message will show up in the terminal

---------------------------------------------------------------------------
   The new Vartheme BS4 Sub-Theme were created at "/var/www/html/mysite/docroot/themes/custom/mytheme :)" 
---------------------------------------------------------------------------

Activate the New Theme

  • Go to Appearance in the administration of the Varbase site.

  • Search for the name of the newly generated theme

  • Click on Install and set as default.

  • Navigate to the home page to check if the new theme is the default theme.

Initiation Commands

First step to do after creating a new theme.

Change directory to the new theme in the terminal then run only gulp without arguments.

Run this command ones after creating a new sub theme

Run it again ones after updating the Bootstrap 4 library with yarn install

cd PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME
gulp
[10:55:40] Using gulpfile PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME/gulpfile.js
[10:55:40] Starting 'default'...
[10:55:40] Starting 'compile'...
[10:55:42] Finished 'compile' after 2.44 s
[10:55:42] Starting 'move_bootstrap_js_files'...
[10:55:43] Finished 'move_bootstrap_js_files' after 18 ms
[10:55:43] Starting 'move_popper_js_files'...
[10:55:43] Finished 'move_popper_js_files' after 3.89 ms
[10:55:43] Starting 'watch'...

or with Yarn

yarn theme:init

Compiling SCSS to CSS

  • For example change the color value for the primary color in scss/bootstrap-variables.scss file to test compiling SASS files to CSS

Then run gulp compile ones to compile every time the SCSS source changes.

cd PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME
gulp compile
[11:22:30] Using gulpfile PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME/gulpfile.js
[11:22:30] Starting 'compile'...
[11:22:33] Finished 'compile' after 2.54 s

or with Yarn

yarn theme:build

Watching SCSS Changes

Increase maximum watched SASS files by

echo fs.inotify.max_user_watches=524288
 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Run gulp watch to keep watching for changes. This command will auto compile on each save of changes for SCSS files.

cd PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME
gulp watch
[11:25:53] Using gulpfile PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME/gulpfile.js
[11:25:53] Starting 'watch'...

or with Yarn

yarn theme:watch

Cloning a Project

On the state of working in a team in a project, the created theme could be don by other member of the team.

When the theme get committed by git for example, the node_modules folder will not be committed. As it is listed in the .gitignore file.

After cloning a project with a Vartheme Sub theme.

Run the following commands to get all development tools

cd PROJECT_DIR_NAME/docroot/themes/custom/THEME_NAME
yarn install
gulp

2. Install npm and

3. Install

4. Install

Varbase Project
Understanding The Vartheme Base Theme
https://getbootstrap.com/docs/4.0/getting-started/build-tools/
sed
gawk
nodejs
Yarn
Gulp