# How to get Haddock for Hackage to generate correctly?

**URL:** <https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649>\
**Category:** Learn\
**Created:** [February 4, 2026, 8:57am UTC](https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649 "2026-02-04T08:57:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [February 4, 2026, 8:57am UTC](https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649/1 "2026-02-04T08:57:05Z")

</div>

There are a few resources I’ve found that point out how to generate Haddocks for Hackage:

- [How to upload haddocks to Hackage? · Issue #5821 · haskell/cabal · GitHub](https://github.com/haskell/cabal/issues/5821#issue-395048114)
- [Uploading packages and package candidates | Hackage](https://hackage.haskell.org/upload)
- [[Resolved] What steps are needed to upload docs to hackage?](https://discourse.haskell.org/t/resolved-what-steps-are-needed-to-upload-docs-to-hackage/4575)

They all say you should generate Haddocks with

```haskell
cabal haddock ... --haddock-for-hackage --enable-doc

```

but when I do this half of the documentation is missing. Compare:

- Generated by Hackage itself: [Bluefin.State](https://hackage-content.haskell.org/package/bluefin-0.2.7.0/docs/Bluefin-State.html#v:evalState)
- Generated by the command line above and uploaded by me: [Bluefin.State](https://hackage-content.haskell.org/package/bluefin-0.4.0.0/docs/Bluefin-State.html#v:evalState)

You can see that all the function documentation is missing from the latter. EDIT: I’ve now uploaded the fixed version, so it not longer exhibits the bad behaviour.

What’s weird is that when I run the `cabal haddock` command locally it also generates `bluefin-internal` documentation, because it’s a dependency, and _that_ documentation is correct. Now `bluefin` just re-exports identifiers from `bluefin-internal`, but somehow the documentation is not getting pulled over too. Furthermore, if I run `cabal haddock` without `--haddock-for-hackage`, everything is fine.

The documentation is generated correctly when Hackage does it, so I guess I must be missing a flag or some other form of configuration. Does anyone know what?

* * *

EDIT: The `--help` says:

```haskell
 --haddock-for-hackage Collection of flags to generate documentation

```

but it’s not clear _what_ flags `--haddock-for-hackage` stands in for so I can’t play around with those to debug. Does anyone know what the collection of flags is?

---

<div class="post-metadata">

**Author:** ![sjoerdvisscher](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/sjoerdvisscher/32/1275_2.png) [@sjoerdvisscher](https://discourse.haskell.org/u/sjoerdvisscher)\
**Post date:** [February 4, 2026, 10:28am UTC](https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649/2 "2026-02-04T10:28:53Z")

</div>

> [@tomjaguarpaw](#):
>
> it’s not clear _what_ flags `--haddock-for-hackage` stands in for

It seems to be mostly this:

> <https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Haddock.hs#L269>

---

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [February 4, 2026, 11:15am UTC](https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649/3 "2026-02-04T11:15:59Z")

</div>

Thanks! Based on that I ran this command line and all the documentation was fine:

```plaintext
cabal haddock bluefin \
   --haddock-all \
   --enable-doc \
   --haddock-hoogle \
   --haddock-html \
   --haddock-hyperlink-source \
   --haddock-quickjump

```

Can you see anything I’ve obviously missed? (I should try the location and contents flags, but I assumed they wouldn’t make any difference.)

* * *

EDIT: It seems that I can get the docs to build properly by doing this:

```plaintext
cabal clean
cabal haddock bluefin                                      
cabal haddock bluefin --enable-doc --haddock-for-hackage

```

You can see the properly-built documentation at [Bluefin.State](https://hackage-content.haskell.org/package/bluefin-0.4.0.0/docs/Bluefin-State.html).

If I don’t have the intermediate `cabal haddock bluefin` then I get the earlier version without the function docs. Somehow something in the intermediate run must store some state that the latter run can pick up. I would be interested to know how the Hackage docbuilder does this.

* * *

EDIT: This seems to be what the Hackage builder uses: [hackage-server/exes/BuildClient.hs at 8ce96799395253ffd45ff8c85bb25423acb98e57 · haskell/hackage-server · GitHub](https://github.com/haskell/hackage-server/blob/8ce96799395253ffd45ff8c85bb25423acb98e57/exes/BuildClient.hs#L746-L758). To my surprise, it doesn’t use `--haddock-for-hacked` and goes via `cabal v1-install`.

---

<div class="post-metadata">

**Author:** ![mpilgrem](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mpilgrem/32/2529_2.png) [@mpilgrem](https://discourse.haskell.org/u/mpilgrem)\
**Post date:** [February 4, 2026, 12:29pm UTC](https://discourse.haskell.org/t/how-to-get-haddock-for-hackage-to-generate-correctly/13649/4 "2026-02-04T12:29:23Z")

</div>

See:  
[Document online `Setup.hs haddock --for-hackage` by mpilgrem · Pull Request #11325 · haskell/cabal](https://github.com/haskell/cabal/pull/11325)
