# Hugo frontmatter aliases do not get created for custom content types

**URL:** <https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794>\
**Category:** support\
**Created:** [March 26, 2019, 9:49pm UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794 "2019-03-26T21:49:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dottjt](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@dottjt](https://discourse.gohugo.io/u/dottjt)\
**Post date:** [March 26, 2019, 9:49pm UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/1 "2019-03-26T21:49:34Z")

</div>

So, I’m essentially using Hugo as a JSON API for my content.

Hugo creates a folder (with an index.json) for each page that I create in my /content folder. However, I’ve noticed it won’t create any additional folders for any additional aliases that I define within the front matter.

How would I essentially go about doing this, so Hugo will generate those additional folders, since that’s really the only solution that would work in my case?

Any help would be greatly appreciated 🙂

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [March 27, 2019, 1:42am UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/2 "2019-03-27T01:42:50Z")

</div>

Please see Requesting Help linked below and share your code so that we can help you troubleshoot this

> [@Requesting Help](https://discourse.gohugo.io/t/requesting-help/9132):
>
> Please read and follow the below guidelines before asking for help in the forum. [DOCS](https://gohugo.io/documentation/) | [THEMES](https://themes.gohugo.io/) | [NEWS](https://gohugo.io/news/) | [GITHUB](https://github.com/gohugoio/hugo) | [FAQ](https://gohugo.io/troubleshooting/faq/) | [RELEASE NOTES](https://github.com/gohugoio/hugo/releases)How to Request Help Welcome to the Hugo forums and thanks for using Hugo! The below are a few friendly tips on getting help from the other Hugo volunteers in this forum. Some Knowledge Required Dare we say that while Hugo is indeed pretty magical, it is not meant to be a “magic wand” to suddenly give you a published website a la Square Space or Wordpress. You …

---

<div class="post-metadata">

**Author:** ![dottjt](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@dottjt](https://discourse.gohugo.io/u/dottjt)\
**Post date:** [March 27, 2019, 2:32am UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/3 "2019-03-27T02:32:42Z")

</div>

@zwbetz Thank you and apologises for not understanding the rules!

Source code: [https://github.com/dottjt/nfd-api](https://github.com/dottjt/nfd-api)

I expected that when generating the files, it would create new JSON files for the alias slugs defined within the font-matter of content located within content/practices. However, it only creates files associated with the slug of the post.

My understanding is that it will generate separate html files for those alias slugs, however it does not seem to be doing the same for Json generated content.

I’m not 100% sure if this is relevant, but this is what I have defined in my config.toml for custom data types:

```auto
[outputs]
  home = ["HTML", "JSON"]
  section = ["HTML", "JSON"]
  page = ["HTML", "JSON"]

```

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 27, 2019, 4:09am UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/4 "2019-03-27T04:09:51Z")

</div>

Hi,

So according to [How Hugo Aliases Work](https://gohugo.io/content-management/urls/#how-hugo-aliases-work),

> When aliases are specified, Hugo creates a directory to match the alias entry. Inside the directory, Hugo creates an `.html` file specifying the canonical URL for the page and the new redirect target.

So, the way I understand that is that it is primarily meant to serve as redirect, not as a mirror page. Perhaps that is why? I am not a Hugo dev though.

---

<div class="post-metadata">

**Author:** ![dottjt](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@dottjt](https://discourse.gohugo.io/u/dottjt)\
**Post date:** [March 27, 2019, 6:23am UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/5 "2019-03-27T06:23:42Z")

</div>

Actually, I think I know what’s happening.

So what’s happening is that all the aliases are generated being at the root level. So for example in public/alias-slug as opposed to in the section level i.e. public/practices/alias-slug.

Furthermore, it’s not generating JSON for aliases.

I wonder how I could generate these aliases at a section level, as well as generate JSON for those aliases.

---

<div class="post-metadata">

**Author:** ![zwbetz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/zwbetz/32/16088_2.png) [@zwbetz](https://discourse.gohugo.io/u/zwbetz)\
**Post date:** [March 27, 2019, 3:18pm UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/6 "2019-03-27T15:18:16Z")

</div>

> [@dottjt](#):
>
> So what’s happening is that all the aliases are generated being at the root level. So for example in public/alias-slug as opposed to in the section level i.e. public/practices/alias-slug.

When defining your alias, you must specify the full path. For example in file

```plaintext
content\practices\DONE--AOA--P--dissolve-your-visual-field.md

```

You currently have the alias defined as

```plaintext
aliases: [
  "dissolve-it-down"
]

```

But it needs to be

```plaintext
aliases: [
  "/practices/dissolve-it-down/"
]

```

> [@dottjt](#):
>
> Furthermore, it’s not generating JSON for aliases.

~~Why should it? The alias is an HTTP redirect. So once the user is redirected to the new page, they will get the new JSON there.~~

I see what you’re saying now. Yeah

```plaintext
/practices/dissolve-it-down/index.json

```

Does not redirect to

```plaintext
/practices/dissolve-your-visual-field/index.json

```

Am not sure how to make this happen.

* * *

Well, you could do this…

```plaintext
aliases: [
  "/practices/dissolve-it-down/",
  "/practices/dissolve-it-down/index.json"
]

```

But then that redirects the JSON page to your new HTML page, not what you want

* * *

I see you’re using Netlify. You could use [Netlify Redirects](https://www.netlify.com/docs/redirects/) for your json

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [March 27, 2019, 7:54pm UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/7 "2019-03-27T19:54:11Z")

</div>

The alias system in Hugo was not created for your use case; it is based on the web pattern of loading a web page with a redirect timer. That pattern isn’t _great_ for handling redirects in an API.

Obviously when you look at how Netlify redirects work, you might be able to get creative, but if you are doing redirects, that means you are feeding a web server a list of URLs mapped to other URLs. What I mean is: how would you do this without Hugo? Work back from there.

At least this is how I think it works. I don’t know that much JSON stuff, so maybe I’m off on how redirecting API endpoints is…

---

<div class="post-metadata">

**Author:** ![dottjt](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@dottjt](https://discourse.gohugo.io/u/dottjt)\
**Post date:** [March 27, 2019, 9:20pm UTC](https://discourse.gohugo.io/t/hugo-frontmatter-aliases-do-not-get-created-for-custom-content-types/17794/8 "2019-03-27T21:20:53Z")

</div>

> [@zwbetz](#):
>
> But it needs to be
> 
> ```auto
> aliases: [
> "/practices/dissolve-it-down/"
> ]
> 
> ```

This is excellent and exactly what I needed. Thank you so much.

> [@zwbetz](#):
>
> Well, you could do this…
> 
> ```auto
> aliases: [
> "/practices/dissolve-it-down/",
> "/practices/dissolve-it-down/index.json"
> ]
> 
> ```
> 
> But then that redirects the JSON page to your new HTML page, not what you want

Actually, that is what I want! (I think, I’ll have to try it out)

Essentially I’ll have to have a redirect from “/practices/dissolve-it-down/index.json” to the proper index.json in Netlify, but I think that’s the right answer here 🙂

Thank you so much for your help! It’s not perfect, but obviously I’m using Hugo outside of it’s use-case.

Definitely I’m liking the idea more and more of using static site generators as APIs. It’s a lot easier than setting up a database etc.
