diff --git a/scripts/build_html_examples.sh b/scripts/build_html_examples.sh
index 8afa61d4b8..b5a8edc0b1 100755
--- a/scripts/build_html_examples.sh
+++ b/scripts/build_html_examples.sh
@@ -31,8 +31,10 @@ else
ln -s -T "$SYMLINK_TARGET" lvgl
fi
+# Grab the path to emscripten's port examplelist.c before changing to LVGL's directory
+EXAMPLE_LIST_C=$(pwd)/examplelist.c
cd lvgl
-scripts/genexamplelist.sh > ../examplelist.c
+scripts/genexamplelist.sh > $EXAMPLE_LIST_C
cd ..
# Generate lv_conf