---
# System prepended metadata

title: Tag Discovery ++

---

# Tag Discovery ++

> [!Important]
> Read [Relative Custom Tags](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) in our docs first

---

**TL;DR:** Tag discovery should dig into non-tag directories beneath `tags/`

---

As it stands, our tag discovery is _shallow_. When there is a `tags/` directory, Marko looks at its top-level files & folders to see if any are valid Marko tags. This means that there isn't any form of grouping.

```
tags/
  a.marko
  b/
    index.marko
  c/
    c.marko
  group/
    d.marko
```

In this example, `<a>`, `<b>`, and `<c>` are discoverable as tags but `<d>` is not.

As projects get larger and more custom tags are added, sometimes it leads to bloated `tags/` directories.

```
src/
  routes/
    +page.marko
    blog/
      +page.marko
  tags/
    const-debounce.marko
    icon-chevron.marko
    icon-hamburger.marko
    icon-plus.marko
    let-localstorage.marko
    testimonials.marko
    code-block.marko
    comments.marko
```

Our current recommendation here is to move tags closer to where they are used. **This will continue to be our recommendation**, regardless of this proposal.

```
src/
  routes/
    _home/
      +page.marko
      tags/
        testimonials.marko
    blog
      +page.marko
      tags/
        code-block.marko
        comments.marko
  tags/
    const-debounce.marko
    icon-chevron.marko
    icon-hamburger.marko
    icon-plus.marko
    let-localstorage.marko
```

Of course, this doesn't fully solve the problem. Some tags, like icons in this case, must be accessible globally!

## Proposal

**Tag discovery should dig into all folders below `tags/` that aren't tags themselves**.

This means that we would be able to make categories, and tags would still be discoverable:

```
tags/
  utils/
    const-debounce.marko
    let-localstorage.marko
  icons/
    icon-chevron.marko
    icon-hamburger.marko
    icon-plus.marko
```

## Tradeoffs

This seems great at first, but it does come with some baggage.

First, the tag discovery algorithm will be doing more work than it was before. This _should_ be negligible, especially since the recursive search only starts when a `tags/` directory is present.

Also, some tags that weren't discovered before now _will_ be discovered. We were most worried about test files being picked up, but since the algorithm would _stop_ at directories that were also tags this shouldn't be a problem:

```
tags/
  my-button/
    examples/
      not-discovered.marko
    my-button.marko
  my-input/
    also-not-discovered.marko
    index.marko
```

## Thoughts?

Let's start a discussion about this! Reach out on [Discord](https://discord.com/channels/725013179465203793/1423366789735256105) if you have any questions or concerns, or if you like the idea :smile: