How can I install a Typst package from a Github repo?

Hello,
I’m trying to use Gihub repo of what seems to be a Typst “package”

It has a “typst.toml” file at the root, and folders for modules, template and fonts.

In the “main” file, cv.typ, there’s an import “#import@local/typcv:0.1.0”: *”

When I try to compile this package or watch it, I get an error:
typst watch --root . --font-path ./src/fonts/ ./template/cv.typ ./output/cv.pdf
typst compile --root . ./template/cv.typ ./output/cv.pdf --font-path ./src/fonts/

watching ./template/cv.typ
writing to ./output/cv.pdf

[12:45:26] compiled with errors

error: package not found (searched for @local/typcv:0.1.0)
  ┌─ template/cv.typ:1:8
  │
1 │ #import "@local/typcv:0.1.0": *
  │         ^^^^^^^^^^^^^^^^^^^^

I replaced the import with
#import “…/lib.typ”
And that part seems to work, but then I get another error:

$ typst compile --root .   ./template/cv.typ ./output/cv.pdf --font-path ./src/fonts/
error: unknown variable: cv
  ┌─ template/cv.typ:5:7
  │
5 │ #show: cv
  │   

The cs variable is defined in the lib.typ file.
I’m really at a loss here.
How is this supposed to work?

Is your import statement missing the asterisk? The full line should be

#import "../lib.typ": *
1 Like

You need to install the template as a local package in order to use the @local import. The path where to install the package depends on your OS, see GitHub - typst/packages: Packages for Typst. for the instructions.

1 Like

Thanks so much! Both answers were on point! And so quick!
I can’t tell you how much time I spent fiddling with this.
All working now!
Thanks again!

Hi @fc1, don’t forget to tick one of the responses if you got a satisfying answer. The answer you choose should usually be the response that you found most correct/helpful/comprehensive for the question you asked.

I have also changed your post’s title to bring it in line with the question guidelines and thus make it easier to understand from the title:

Good titles are questions you would ask your friend about Typst.

2 Likes