You can use submodules with GitHub Pages with a few conditions.

If your GitHub Pages site repository contains submodules, they will automatically be pulled in when the Page is built.

Submodule requirements

You can only use submodules with GitHub Pages sites that point to public repositories. Using a submodule that points to a private repository is not possible because the Pages server cannot access private repositories. If you're adding a submodule to a private GitHub Pages repository, your pages site will still be published publicly.

Make sure you use the https:// read-only URL for your submodules, including nested submodules. You can make this change in your .gitmodules file.