# Data attributes for inclusion and exclusion are not working

**URL:** <https://discuss.elastic.co/t/data-attributes-for-inclusion-and-exclusion-are-not-working/359656>\
**Category:** Elasticsearch\
**Created:** [May 16, 2024, 4:32pm UTC](https://discuss.elastic.co/t/data-attributes-for-inclusion-and-exclusion-are-not-working/359656 "2024-05-16T16:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dongmyoung\_Kim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dongmyoung_kim/32/134563_2.png) [@Dongmyoung\_Kim](https://discuss.elastic.co/u/Dongmyoung_Kim)\
**Post date:** [May 16, 2024, 4:32pm UTC](https://discuss.elastic.co/t/data-attributes-for-inclusion-and-exclusion-are-not-working/359656/1 "2024-05-16T16:32:00Z")

</div>

I've implemented the "data-elastic-exclude" attribute in the body tag and "data-elastic-include" in specific content sections to ensure that only those parts are indexed by Elasticsearch web crawler. However, it appears that this functionality isn't functioning as expected. Despite these attributes, the web crawler is gathering all content within the body, including navigation, sidebar, and footer elements. Are there any specific requirements or considerations I should be aware of when using "data-elastic-exclude" and "data-elastic-include"? Can I exclude header and footer at least from body\_content?

Here's the relevant code snippet:

```auto
<body data-elastic-exclude data-paywall-content-type="premium">
   ...
   <section data-elastic-include class="content article-content">
        {{ article.content|safe }}
   </section>
   ...
</body>

```

---

<div class="post-metadata">

**Author:** ![sarahg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sarahg/32/137660_2.png) [@sarahg](https://discuss.elastic.co/u/sarahg)\
**Post date:** [October 11, 2024, 7:49pm UTC](https://discuss.elastic.co/t/data-attributes-for-inclusion-and-exclusion-are-not-working/359656/2 "2024-10-11T19:49:11Z")

</div>

@Dongmyoung_Kim Did you resolve this, or find a workaround? We are seeing the same issue.

I have a `data-elastic-include` attribute on a `div` that wraps my main content, which is the only thing on a page we want to index.

**Expected behavior** : The global navigation on my site, which is not in this div, should not be indexed.

From the [docs](https://www.elastic.co/guide/en/enterprise-search/current/crawler-content.html#crawler-content-inclusion-and-exclusion):

> For all pages that contain HTML tags with a `data-elastic-include` attribute, the crawler will only index content within those tags.

**Actual behavior** : The global navigation is indexed and is included in the `body_content` field.

This negatively impacts both our results and the snippets shown alongside them.

Edit: This seems like a bug to me. I've opened an issue here: [Crawler attributes like `data-elastic-include` are ignored · Issue #152 · elastic/crawler · GitHub](https://github.com/elastic/crawler/issues/152)
