Adding the is_front variable to a Paragraphs template Is the is_front variable not available in a Paragraphs template override?

I'm trying to do the following:

    &lt;div{{ attributes.addClass(classes) }}&gt;
      &lt;div class="row"&gt;
        &lt;div class="col-sm-7"&gt;
          {% if is_front and content.field_section_title %}
            &lt;h2&gt;{{ content.field_section_title }}&lt;/h2&gt;
          {% elseif content.field_section_title %}
            &lt;h4&gt;{{ content.field_section_title }}&lt;/h4&gt;
          {% endif %}

          {{ content.field_text }}
        &lt;/div&gt;
        &lt;div class="col-sm-5"&gt;
          {{ content.field_section_image }}
        &lt;/div&gt;
       &lt;/div&gt;
     &lt;/div&gt;


However, when I set a node that uses this paragraph type as the homepage, it doesn't take the is_front condition and just uses the h4 tag instead of the h2 which is what I would like for it to do.

Is there a way for my paragraphs templates to use the is_front condition? Or is there a different way to go about this?
You should be able to add this with a preprocess function in mytheme.theme of your theme.

/**
 * Implements hook_preprocess_paragraph().
 * @param $variables
 */
function mytheme_preprocess_paragraph(&amp;$variables) {
  $variables['is_front'] = Drupal::service('path.matcher')-&gt;isFrontPage();

  // Ensure the cache varies correctly.
  // Drupal 8.2.x or lower
  $variables['#cache']['contexts'][] = 'url.path';

  // Ensure the cache varies correctly.
  // Drupal 8.3.x+
  $variables['#cache']['contexts'][] = 'url.path.is_front'; 
}


This should add is_front as a variable to any paragraph twig template. Clear cache after adding this code.

Per 4k4's comment, if this is Drupal 8.3 you will also need to add a cache context.