How to add the title field to the manage display page in Drupal

Published Jan 20, 2023
Updated Mar 16, 2023
By Simon

Using Show Title and a deeper look at the options to position the title including work being done in Drupal core.

One thing that Drupal has always done is treat the default title of content types to be a sacred field. What I mean by that is, it is treated differently than other fields and it is hard to modify. Without getting technical about why this is, I will share a couple of examples I have come across where this has been an issue.

The first issue which I have covered in another article is when you want to add HTML to the title field or in the case of this article, using the Show Title module, you want to control the weight and positioning of the title as part of the content type instead of being placed using the system block management as illustrated below.

Image
drupal block layout page showing title block
The default Drupal block layout page showing the title block position in the content region.

To overcome this issue we need to install a module, well installing a module is the easiest solution and one of these modules is the show title module.

! Note
There are a few solutions to this issue and it is an active issue for Drupal core. The main work is being done in the contributed module Manage display and if you are wanting to expose the title on the manage display page then Manage Display module is probably the way to go. That said I haven't used the Manage Display module and Show Title does do the same. In this article I bring up a few ideas worth thinking about and for a quick fix Show Title may work for you.

The Show Title module

Info

https://www.drupal.org/project/show_title

Actively maintained <strong> No, but considered feature-complete by its maintainers. It has a small user base of ~500 at the time of writing.
Requires No extra requirements.
Libraries No library.

Install either using the UI or composer.

Basics

There is no configuration needed except visiting the manage display page for the content types you want to use it on. From here you can position where you want the title filed to be.

Manage > Structure > Content types > Article > Manage display
admin/structure/types/manage/article/display

Perms

There are no permissions to set. If you can modify the manage display page you can change the position of the title.

How does the Show Title module work?

Show Title shows the title on the manage display page as illustrated below, this allows you to easily re-order the field in the UI which is then rendered on the content page in that position, albeit which out an h1 tag. However, you can use the field group module to wrap the Show title field in any element, so you can use that.

Image
manage display page with a title using show title module  for drupal

If you want to create a custom template, you can use the {{ label }} value to render your title as you would normally and wrap it in an h1 tag that way.

The nice thing about Show Title is it removes the title from the default block position so you don't need to hide it using CSS or remove/disable it from the block position or by using the block UI configuration to remove the title from some paths. All the former suggestions could be work rounds but Show Title makes this easy.

Other solutions

  • You could hide the field on the block placement page and then place it manually by hard coding it in your templates instead. This means you will need to add it to all the templates and maybe use conditional code to hide it on certain types of routes. Effectively this is what Show Title does for you all with the UI.
  • You could use a second field and disable and hide the title as discussed above. The thing with this type of solution would still need to add the title as it is used to generate URLs and in Views. 

These above solutions could work but as pointed out, you will only end up adding complexity. It really depends on what you are trying to do but that is a story for another day. 

Is Drupal core changing this?

As stated in the note at the top, there is work being carried out on this so eventually, this won't be an issue. However, in the meantime, you will need to use one of the solutions outlined above or the Show Title module. Also, as mentioned, the Manage Display module works if you have time to explore it.

For more information on Drupal, the issue is labelled with [META] Expose Title and other base fields in Manage Display

Conclusion

Show Title works nicely to give content managers and site builders the ability to position the title on the content type manage display UI  but it doesn't make the new title an h1. To add the h1 tag you can install and use the field group module so not really a big issue and field group module is a great UX enhancement in itself.

The module does provide a new pseudo field that can be added to the page template if you are a theme builder. This allows you to leave the default block placement of titles for everything and then hard-code the titles for the content types that use it. This is what I did and as such, I feel it is a good solution as you only have to deal with the new title field for where you want to change it on a content type by content type basis.

Do note, however, if you use a content type on your home page the Show Title module won't work in this situation. The title will show in the block placement position or not at all so you will need to hard code it into the template to set it just for the home page or create a dedicated content type for the home page.

In the right situation, Show title is a great helper module to enable site builders and themers to expose the title field on the manage display page. However, if you have time then exploring the Manage Display module may be a better option especially if you are keeping your site up to date. i.e it requires >=9.4 or patching of older versions. I will check this out in due time as Show Title works and with the patch can be used in Drupal 10.

Thanks for reading. If you want to learn more about Front-end development, using Drupal, and modern frameworks be sure to sign up for the newsletter below. Until next time have a great day, you deserve it!