Change Drupal 8 User Password

Changing the password of Drupal 8 user is easily done using drush. As of this post, the Drush version I’m using is version 9.5.2 and was installed in the project’s directory using composer (composer require drush/drush).

The syntax is:

drush upwd [user]  [password]


drush user:password [user]  [password]

For example, to change the admin user password:

drush upwd admin "another_password"

Add JS to Drupal 8 website

For the last two months I’ve been working on my first Drupal 8 website. Its quite a huge leap from version 7 but the new features and methodology of working with a Drupal CMS is way better.

One bit I struggled with was inserting a custom Javascript file that made use of jQuery functions. This is how I managed to do it (I assume you know how to develop a Drupal 8 theme and how to develop with Drupal 8 in general):

In the theme_name.libraries.yml file, define you library and add the js file i.e.

  js/main.js: { every_page: true }
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

Save the file. Next, edit the to add the library i.e.

 - 'theme_name/custom-js'

Save the file. Open your custom Javascript file e.g. main.js and add you code in the following format. The code demo below ensures Drupal’s no-conflict policy for Javascript libraries. We want to ensure that the different libraries you use function independently. This example caters for jQuery:

jQuery(document).ready(function($){// insert your code here


Save your file and you should be good to go.

Create Drupal 8 Custom Page Template

Simply place the following code in the .theme (theme_name.theme) file that is located inside your theme folder. Replace theme_name with the actual name of your Drupal theme.

function theme_name_theme_suggestions_page_alter(array &$suggestions, array $variables) {
// Add content type suggestions.
if ($node = \Drupal::request()->attributes->get('node')) {
array_splice($suggestions, 1, 0, 'page__' . $node->getType());

Then create a file under the template folder and name it according to your node content type e.g.


Then add your custom code for that particular page.

Making Drupal Static

After a long search to understand how I can make a dynamic Drupal website be static (so that it can run offline), I came across this interesting article:

It describes a few methods of generating an offline version of a Drupal website. I’ll post my results and observations in a future post.

Happy coding!