# Template functions for semantic version comparisons

**URL:** <https://discourse.gohugo.io/t/template-functions-for-semantic-version-comparisons/40501>\
**Category:** dev\
**Created:** [September 13, 2022, 5:16am UTC](https://discourse.gohugo.io/t/template-functions-for-semantic-version-comparisons/40501 "2022-09-13T05:16:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [September 13, 2022, 9:49pm UTC](https://discourse.gohugo.io/t/template-functions-for-semantic-version-comparisons/40501/3 "2022-09-13T21:49:25Z")

</div>

We already have a `VersionString` type that supports all of the above ops. I’m not sure if it’s fully semver compatible, but it’s what Hugo uses, so it’s … Hugo compatible. I think it’s exposed in a template somehow, but the main take is that we don’t want to re-implement all of the ne/ge/gt … in yet another API.

So instead of

```auto
{{ semver.Gt "v0.100.0" "v0.101.3" }} ---> false

```

You would do:

```auto
{{ gt (ver "v0.100.0") ver("v0.101.3") }} ---> false

```

We certainly do some magic in other situations as well, so we could also maybe do

```auto
{{ gt "v0.100.0" "v0.101.3" }} ---> false

```

But that said, I’m not sure where this came from. We at least should have enough tools to determine if the current Hugo version is before/after a given string.

---

_[View the full topic](https://discourse.gohugo.io/t/template-functions-for-semantic-version-comparisons/40501)._
