# Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

I have a Zotero bibliography in Overleaf. I use biblatex.

\usepackage[backend=biber,citestyle=authoryear]{biblatex}


Bibliography entries look like:

@book{de_saint-gervais_uniformization_2016,
title = {Uniformization of {Riemann} {Surfaces}},
isbn = {978-3-03719-145-3},
url = {https://www.ems-ph.org/books/book.php?proj_nr=198&srch=series%7Chem},
urldate = {2019-02-03},
author = {de Saint-Gervais, Paul Henri},
year = {2016},
doi = {10.4171/145}
}


In the bibliography down the paper the reference shows like this: There is the DOI, great, but also the URL which is unnecessary when the DOI is there.

How can I remove the URL when the DOI is present?

I really thought there would be a duplicate, but I could not find a good one. (Biblatex: use doi only if there is no URL asks for the opposite and has a sourcemap solution. Redundancy in bib file: conditionally suppress url if same as doi? is asking for something slightly different and is not specific to biblatex, but has some biblatex answers, none of them uses a sourcemap, though. Print url only if doi not present is very close, the question additionally asks about eprint, but that could probably be ignored.)

My preferred solution would be to use a Biber sourcemap to completely remove the url and urldate field if the doi is present.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=doi,final]
\step[fieldset=url,null]
\step[fieldset=urldate,null]
}
}
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{de_saint-gervais_uniformization_2016,
title   = {Uniformization of {Riemann} {Surfaces}},
isbn    = {978-3-03719-145-3},
url     = {https://www.ems-ph.org/books/book.php?proj_nr=198&srch=series%7Chem},
urldate = {2019-02-03},
author  = {de Saint-Gervais, Paul Henri},
year    = {2016},
doi     = {10.4171/145}
}
\end{filecontents}

\begin{document}
\cite{de_saint-gervais_uniformization_2016}
\printbibliography
\end{document}