# Insert package version number at top of documentation

**URL:** <https://discourse.julialang.org/t/insert-package-version-number-at-top-of-documentation/115350>\
**Category:** New to Julia\
**Tags:** documenter\
**Created:** [June 7, 2024, 9:05pm UTC](https://discourse.julialang.org/t/insert-package-version-number-at-top-of-documentation/115350 "2024-06-07T21:05:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loisel/32/50626_2.png) [@loisel](https://discourse.julialang.org/u/loisel)\
**Post date:** [June 7, 2024, 9:05pm UTC](https://discourse.julialang.org/t/insert-package-version-number-at-top-of-documentation/115350/1 "2024-06-07T21:05:17Z")

</div>

Hello,

I like to have the version number of the package included in the documentation, so that you can immediately tell if you’re reading the right version of the documentation. To do this, I’ve put the following near the top of my `docs/src/index.md` (not checked in to github yet):

````julia
```@eval
using Markdown
using Pkg
m = Pkg.Operations.Context().env.manifest
v = string(m[findfirst(v->v.name == "MultiGridBarrier", m)].version)
md"# MultiGridBarrier $v"
```

````

A couple of questions.

1. Is this really the right way to get the version number? If I had something like `Pkg.getversion(MultiGridBarrier)`, I would be slightly more confident that it got the right package, as opposed to my hand-coded `findfirst` search. Also, is this part of the `Pkg` API really public?
2. The `Documenter` [documentation](https://documenter.juliadocs.org/stable/man/syntax/#@eval-block) says that `@eval` is a sin in the eyes of the lord and that I should feel guilty for using it. Is this so?

Thanks,

S

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [June 7, 2024, 9:26pm UTC](https://discourse.julialang.org/t/insert-package-version-number-at-top-of-documentation/115350/2 "2024-06-07T21:26:40Z")

</div>

Since Julia 1.9, there is `pkgversion()` which does what you need if I understand you right.

---

<div class="post-metadata">

**Author:** ![loisel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/loisel/32/50626_2.png) [@loisel](https://discourse.julialang.org/u/loisel)\
**Post date:** [June 7, 2024, 9:48pm UTC](https://discourse.julialang.org/t/insert-package-version-number-at-top-of-documentation/115350/3 "2024-06-07T21:48:42Z")

</div>

That’s a huge improvement already, thanks! I’m glad I asked.
