What is Quarto?
From the Quarto webpage, it is
An open-source scientific and technical publishing system
Quarto can be used to create documentation pages, scientific notebooks, professional presentations, and websites (like this one!).
This system is useful for creating notes, particularly these containing Python/R code
. And in contrast with jupyter notebooks, it offers a wide variety of ways to share these notes.
Install Quarto on a remote server (HPC)
In this post, two options are presented to install Quarto on a HPC server. The first option installs Quarto in a conda
virtual environment. You can use this option if you don’t need or want to perform additional configuration and/or you are planning to use a single virtual environment for authoring your documents. The second option installs Quarto in your home directory. That works great from creating code-less documents, to authoring documents that require different virtual environments (one per document).
Option 1. Install Quarto in a conda
virtual environment
For this option you should have conda
installed in your home directory. I recommend using miniforge if you don’t have conda
already.
Activate the virtual environment from where you will use Quarto, i.e. conda activate my-venv
(change my-venv
with the actual name of your environment).
If you don’t have a virtual environment, start by creating one instead of installing packages in the base
environment.
Install quarto
from the conda-forge
channel as follows.
conda install -c conda-forge quarto
You are ready to render and preview documents from the command line!
Option 2. Install Quarto on your home directory
Download the Quarto source code for Linux x86 Tarball from their official website into your home directory.
You can download the source code by copying the address link of the download, and using wget
to download it directly into your home directory.
Download the source code with wget
using the following command (change X.X.X
to the latest version available).
wget https://github.com/quarto-dev/quarto-cli/releases/download/vX.X.X/quarto-X.X.X-linux-amd64.tar.gz
If you are installing it in your PC, you can use the installer that matches your OS.
Decompress the source code in a location of your preference within your home directory, like /home/$USER/opt/
.
You might need to create a /home/$USER/opt
directory if it doesn’t already exist.
mkdir /home/$USER/opt
Decompress the source code with tar
by executing the following command (change the version X.X.X
to what you are using first).
tar -C ~/opt -xvzf quarto-X.X.X-linux-amd64.tar.gz
Create a symbolic link to the Quarto executable inside your /home/$USER/bin
directory.
You might need to create a /home/$USER/bin
directory if there is not one already as follows.
mkdir /home/$USER/bin
In general, your /home/$USER/bin
directory should already be in your PATH
environment variable, even if the directory didn’t already exist.
Create a symbolic link to the quarto
executable with the following command (again, change the version X.X.X
first).
ln -s /home/$USER/opt/quarto-X.X.X/bin/quarto /home/$USER/bin/quarto
Check that quarto
is installed by executing the quarto --version
command.
Render and preview documents
You can render and preview your Quarto markdowns by using the following command from the directory where your .qmd
files are located.
quarto preview --no-browser --no-watch-inputs
That will render your documents from the markdowns. For html
, revealjs
, or websites
formats, it will start a local server and provide a link that you can paste in your browser to visualize the result.
Integration with VSCode
You can author Quarto markdowns using VSCode, so you have a nice interface with code highlighting. If you have access to the HPC server, you can use the vscode module to create documents. That is particularly useful when creating jupyter-like notebooks, since you can execute the code directly on the HPC environment.
Install the Quarto extension
The VScode Quarto extension adds markdowns highlighting and commands autocompletion for authoring .qmd
files. It can render and preview the quarto markdown documents by hitting Ctrl Shift K
(Cmd Shift K
on Mac). You can search for the Quarto extension in the Extensions
tab (Ctrl Shift X
/Cmd Shift X
on Mac).
Restart VSCode to make sure that the extension recognizes the Quarto installation in your virtual environments.
If you followed Option 1 to install Quarto in a virtual environment the keyboard shortcut might not work. That happens because installing Quarto through conda
won’t make it visible to where the extension expects it to be.
Additional resources
Now that you have Quarto installed in your home directory, you can start creating your own markdown .qmd
documents. The Quarto authoring guides are the perfect place for learning!