I have a block that I want to show on the front page, but not on every paged page (i.e., don't show it on /front-page?page=1).

How can I achieve this?

  • 1
    This module will give you a bunch of extra conditions, one of them being to see if a URL parameter is or isn't set. Might be worth a try. Use at your own risk, it's very much a work in progress
    – Clive
    Commented Dec 12, 2017 at 9:34

3 Answers 3


Install and enable request_data_conditions module

Then on the configuration of your block add following settings

  • Pages as <front>
  • URL query parameters set
    • page as must not be set
    • page as must equal 0
    • uncheck require all

enter image description here

  • Or page == 0 (can happen sometimes)
    – Clive
    Commented Mar 12, 2019 at 10:10
  • @clive perhaps this is a better setup than ^
    – GiorgosK
    Commented Mar 12, 2019 at 10:25
  • That's what I always go with, yeah :)
    – Clive
    Commented Mar 12, 2019 at 10:35

Have you configured the block as shown in screen shot? enter image description here

If this block is generated using code, also have a look at code also.

  • Yes it is like in screen, but block is showing on <front>/?page.... to, but i want to display block ony on the first page of homepage
    – llSAntASll
    Commented Dec 12, 2017 at 10:49
  • See in this module helps drupal.org/project/block_visibility_groups
    – Sharique
    Commented Dec 12, 2017 at 13:11
  • i installed that module before asking this question ( module dident solved my problem
    – llSAntASll
    Commented Dec 13, 2017 at 15:00

In hook_preprocess_page() add the following code.

$block_entity = Drupal\block_content\Entity\BlockContent::load(BLOCK_ID);// BLOCK_ID
$block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'DISPLAY_VIEW_NAME');
if ($block_view) {
    $variables['page']['my_block'] = $block_view;

In your Twig template, print the block with the following code.

{% if page.my_block %}
  {{ page.my_block }}
{% endif %}

Refference: Render a custom block programmatically

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.