recent posts related to the drupal content management system

Why doesn’t Drupal have a meta description field by default?

I like about 98% of Drupal. A lot of it is well thought out and organized. But some design decisions are real head-scratchers. For example, why in the world does Drupal 8 not include the ability to set a meta description field out of the box? I understand that meta keywords aren’t used by (most) search engines any more, but internet search engines do use the meta description field, and Drupal is supposed to be a CMS for the internet, so why doesn’t it include such a basic CMS feature?

Instead, in Drupal 8 we currently have to rely on an “alpha” third-party module for this capability. It’s cool that this module will eventually emit a bunch of other meta tags that may be important, but IMHO, the meta description field is a basic, out of the box requirement of any CMS. And because of all of these things, I have to spend many hours porting my old Drupal meta descriptions to this new module, which oh by the way is in an alpha state, and may change after I finish my port. #argh

Drupal 8 website not showing images on image/photo nodes

If you have a Drupal 8 website and your images are not showing up on your image/photo nodes, one possible problem (which I just learned) is that your Drupal 8 theme needs to refer to {{ content }} in node.html.twig and not {{ content.body }}.

I don't know why you have to do that, but after four hours of troubleshooting the problem with my own Drupal 8 website/theme, I can confirm that if you don't do it, your images/photos won't be shown on their nodes. (All I was trying to do was to separate content.body from content.comment, and when I did that my images no longer showed up at their nodes/URLs.)

Drupal 8 Twig template "if string is not in array" solution

As a quick note, if you need a Drupal 8 Twig template if/else/then structure where you test to see if a string value is in an array, code like this will work:

{% if node.getType not in ['photo', 'text']  %}
    <div class="similar">
        {{ similar_by_terms }}
{% endif %}

That code can be read as, “If the node type is NOT ‘photo’ or ‘text,’ emit the HTML/Twig code shown.”

What are the Drupal 8 Node class fields (field names)?

I was just trying to modify one of my Drupal 8 template files — node.html.twig — and I couldn’t find any good documentation for what variables/values/fields are in the Drupal 8 Node class, so I dumped some output to my browser, and saw that these are the Node fields:

Drupal 8: How to put a View and a Block between Content and Comments

I’m not going to discuss this code much, but in short, the source code below is for a Drupal 8 preprocess_node function that I use to set variables for (a) a custom view and (b) a custom block. I set the variables in this function, and then display them in my node.html.twig file like this:

{{ similar_by_terms }}

and this:

What are the Drupal 8 Twig template front page file-naming conventions?

Drupal FAQ: What are the Twig template file naming conventions for Drupal 8? Specifically, how do I need to name a template file so it will be used for the front page of my website?

In short, the Drupal 8 Twig “HTML” template file has this name:


and if you want to create a custom HTML front page template, use this name:


The same goes for “page” and “node” files, where the default page template file has this name:

What is the correct name for a Drupal 8 theme front page file (theme file)?

Drupal 8 FAQ: If you want to create a separate theme page for your Drupal 8 theme, what is the correct name of the front page theme file?

I think there are other variations of this, but I use this as the name for my Drupal 8 theme front page: