# How to target a page created with collections via its slug

**URL:** <https://forum.ghost.org/t/how-to-target-a-page-created-with-collections-via-its-slug/36387>\
**Category:** Routing\
**Created:** [February 15, 2023, 6:04am UTC](https://forum.ghost.org/t/how-to-target-a-page-created-with-collections-via-its-slug/36387 "2023-02-15T06:04:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stromfeldt](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/stromfeldt/32/13572_2.png) [@Stromfeldt](https://forum.ghost.org/u/Stromfeldt)\
**Post date:** [February 15, 2023, 6:04am UTC](https://forum.ghost.org/t/how-to-target-a-page-created-with-collections-via-its-slug/36387/1 "2023-02-15T06:04:51Z")

</div>

I’ve got a page, `/external`, that I’ve created with collections in the routes.yaml file:

```auto
collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tags:-[hash-external]
    data:
      external:
        resource: posts
        type: browse
        filter: tags:[hash-external]
        limit: 3
  /external/:
    permalink: /{slug}/
    template: external
    filter: tag:hash-external
    controller: channel
    data: page.external

```

What I need to do with that page is not only target it with `{{#is "page"}}{{/is}}` (which works), but target it specifically via its slug so that other pages aren’t affected. However, things don’t work when I try and single things out via the following:

```auto
{{#is "page"}}
{{#has slug="external"}}
<img>
{{/has}}
{{/is}}

```

Am I just doing it wrong, and/or might there be some other way to accomplish this that I’m not thinking of?

---

<div class="post-metadata">

**Author:** ![RyanF](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/ryanf/32/17448_2.png) [@RyanF](https://forum.ghost.org/u/RyanF)\
**Post date:** [February 15, 2023, 5:27pm UTC](https://forum.ghost.org/t/how-to-target-a-page-created-with-collections-via-its-slug/36387/2 "2023-02-15T17:27:26Z")

</div>

There are a couple of things going on here.

In the `routes` file, are you using the `data` property on the `/:` route? If not, you can remove it, as it’s not essential to the collection, as far as I can tell. The `controller` property isn’t intended to be used on a collection—it’s just for routes, so you can remove it.

I think the reason that your `has` helper isn’t working is that you would need to be in the `page` context to be able to access the slug.

```auto
{{#page}}
  {{#has slug="external"}}

```

However, you can do this with a 1-liner:

```auto
{{#is "external"}}
  Do your thing
{{/is}}

```

This will only return true when on the external collection.

---

<div class="post-metadata">

**Author:** ![Stromfeldt](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/stromfeldt/32/13572_2.png) [@Stromfeldt](https://forum.ghost.org/u/Stromfeldt)\
**Post date:** [February 16, 2023, 1:41am UTC](https://forum.ghost.org/t/how-to-target-a-page-created-with-collections-via-its-slug/36387/3 "2023-02-16T01:41:47Z")

</div>

Yes, both of your suggestions worked, thanks! The second is more concise and specific, so I went with that one.
