Use Theme Regions for Creating Landing Pages in Drupal

Use Theme Regions for Creating Landing Pages in Drupal

Landing pages serve an important role in marketing a website. For creating such pages, you can use certain regions of a theme along with Menus, Views, and Blocks. The custom blocks you create will be used in the landing pages. You can use core Page nodes or create Block with dynamic content.

In this article, learn everything you need to know about using Theme Regions to create landing pages in Drupal 8. Here are the steps you need to follow:
  • Install and Configure PathAuto Module
The first step here is to install the PathAudo module and then configure it. With this module, you will be able to generate path structures for nodes. So install it from the Drupal Module library and then enable it at /admin/modules. You’d also have to install its dependencies, which are cTools and Token.

If you’ve got site administrators, then make sure to allow editor support for PathAuto.

After you’ve installed PathAuto, it’s time to configure it. So navigate into /admin/config/search/path/settings and review the default settings.

Next, you have to set patterns for the URL structure. This will be applied across the website to all URLs. So navigate into /admin/config/search/path/patterns. Then :
  • For Articles content type, set Path Pattern to article/[node:title]
  • For Blog content type, set it to blog/[node:title]
When setting these URL structures, it’s best to consider your site-wide SEO strategy. This will help in higher rankings.
  • Create Page of Any Content Type
Now that you’ve configured PathAuto to create URLs for published blogs and articles, it’s time to start creating article.

PathAuto will automatically create URLs that will have information regarding the context which will then be passed onto Drupal 8 blocks.

For example, for Blog pages, the URL structure will include - /blog/site-title. Similalry, if you create Article pages, the structure for those will be - /articles/text-title

To create a new article or blog, navigate to /node/add. The open the Blocks section by going into /admin/structure/block. Then, locate and click on the “Custom Block Library” tab. Once the tab opens, click on “Add Custom block” button. Technically, the blocks can contain HTML and PHP codes. And you can inlcude images and texts and even embed videos.

Once you’ve made change, save the Block. Then go back to the Block Layout tab where you can see the block listed. This should confirm that you have created the custom block.
  • Add the Block to the Page by URL
Now, you need to work on the Drupal 8 Block configuration page. It contains all the settings you’d need to add and remove design elements on the CMS by code, URL, and Content Type.

In this tutorial, we’re going to be placing different blocks on pages as per the URL structure.

So click on the “Pages” tab after reviewing the Block configuration settings. Then, add the URL /blog/* to the configuration. It will cause the block to the displayed on all blog pages of your Drupal 8 website.

Now, repeat the same process as above and add a new Block in the library. Then you’d have to position the block in the Theme Region and add URL /article/* to the settings.

At the end, you’d have two custom coded blocks on the theme’s same sidebar. One of the blocks will be displayed on all Blog pages with the other being displayed on all Article pages.
  • Build the View Blocks for Dynamic Content
The last step is to build the Views Blocks. This block enable you to create filters for the same PathAuto configuration method.

With Views, you can also create dynamic content. To link to the content, use Node Titles or Thumbnail Images.

So that’s how you use theme regions for creating ladning pages in Drupal 8.
Author
kumkumsharma
Views
2,231
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top