Drupal 8 Tips & Tricks

Submitted by nvovn on Thu, 03/23/2017 - 06:59

Translate Menus

To translate menus as well, you'll have to activate it first.

  1. Go to /admin/config/regional/content-language
  2. Toggle 'Custom menu link' to on
  3. Scroll down and check everything in the custom menu link section is selected
  4. Save
  5. Go to /admin/structure/menu and click on the entries you want to translate
  6. Be aware to change the link as well (e.g. /blog to /de/blog).

Remove Site Name from Top Menu

Thanks to robinK (first comment here) we know how to remove the site name from the menu in Drupal 8.2 and above:

  1. Log in as admin and go to structure → block layout
  2. Under the Header section configure Site Branding
  3. Under Toggle branding elements remove check marks from site logo/name/slogan etc as you wish.
  4. Save settings.

End Maintenance Mode

If you want to end the maintenance mode and are logged out, it seems you have shot yourself in the foot. 

Here comes help: Just go to...


Eliminate Security Issue in Drupal 8.2.x

If you have installed your Drupal instance from scratch it is very likely it'll throw an error related to a security issue in the Status Report. To get rid of this error you should edit settings.php:

$settings['trusted_host_patterns'] = array(

To work with local development instances you have to implement a switch via adding the following lines to the end of settings.php

if (file_exists(__DIR__ . '/settings.local.php')) {
    include __DIR__ . '/settings.local.php'; 

settings.local.php should contain the following lines:

$config_directories = array(CONFIG_SYNC_DIRECTORY => '<your local home directory>',); 
$settings['trusted_host_patterns'] = array(
     '^yourlocalsitename$', '^localhost$' 

Drupal Development Without Cache


The following post is based upon the Youtube video "Drupal 8 Theming - Part 02 - Disable Cache, Enable Twig Debug". Thanks to Ivan!


This post will help you developing Drupal sites. One dangling aspect of Drupal is it's smart caching service, which is good for production environment but just suck for development. Ivan showed us how to disable the cache. And this is the recipe:


1. Within the sites/default/ directory locate settings.local.php. Within this file find/uncomment these lines:

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; 
$settings['cache']['bins']['render'] = 'cache.backend.null';

2. Find/uncomment the following lines within settings.php

if (file_exists(__DIR__ . '/settings.local.php')) {
   include __DIR__ . '/settings.local.php'; 

3. call sitepath/core/rebuild.php

4. create development.services.yml

         class: Drupal\Core\Cache\NullBackendFactory
         debug: true
         auto-reload: true
         cache: false

5. clear cache for the last time

6. check source code in your browser of everything works fine...