@stefanb1, Hi, welcome to the forum!
Please read How to get the best out of this forum, if you haven't done yet.
Thank you for using a code window for showing your code.
But please use the auto format feature of the Arduino IDE before pasting; some errors are easier to detect with well formatted code text.
Please always provide complete information. Display used, with clickable link, processor used, connection module or wiring used to connect.
The code provided should be complete, so anyone can try it directly.
I assume you have successfully run at least one of the examples, e.g. GxEPD2_Example.ino.
Your code might work better if you don't leave out display.firstPage()
for the page loop.
Jean-Marc