Skip to main content

Working with Drupal theme templates

Drupal uses a system of templates to drive its theming layer, templates can be as generic of specific as you want so for example you can create a template which will apply to all nodes or override this on a node by node basis. Templates can be very granular giving you complete control over how your Drupal site looks and feels. Find out more about how to use templates within Drupal to get your Drupal site looking exactly as you want it by reading some of our blog posts below...

Read some of our articles about Drupal theme templates

Localising dates in twig templates

14th Aug 2018

A client noticed the dates on their news articles were not being translated into the correct language. The name of the month would always appear in English, even though all the month names had themselves been translated and showed correctly elsewhere. The problem turned out to be down to the twig filter being used in the template to format the date. This is what we did have:

twig
{% set newsDate = node.getCreatedTime|date('j F Y') %}
{% trans %} {{ newsDate }}{% endtrans %}


So this would produce something like '1 March 2018' instead of '1 März 2018' when...

Read more