Way of specifying base URL for static site generation (github pages)
See original GitHub issueDescribe the feature
Hi there,
Nuxt v2 had an option to specify the base page route, meaning that during generation a base url path would be applied before asset path references. The generator would prepend links to assets in the output HTML with a base url – like so: (base_url)/_nuxt/asset-path.foo
At the moment, attempting to deploy to standard GitHub pages without using a custom URL doesn’t work, as this option no longer exists; the generated files will always reference /_nuxt/asset-path.foo
– and GitHub pages by default mandate a base (the repository name). In effect, this seems to make deploying to GitHub pages no longer possible (unless you use a custom URL, of course); referenced assets will always 404 as it attempts to access them at https://owner.github.io/_nuxt/foo
, instead of https://owner.github.io/repository/_nuxt/foo
Could this option either be re-implemented, or some alternate way of specifying this be found? Or perhaps this option does exist in some form, and I just couldn’t find it in the documentation 😅?
Regards
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide.
- Check existing discussions and issues.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
There is a pending PR to resolve that: https://github.com/nuxt/framework/pull/7984
@tristan-smith I’m softly ashamed to admit I sort of gave up with this setting after painfully debugging it for a few hours! It seems oddly inconsistent with what it does and doesn’t decide to prepend baseUrl with in html links. (Note that I’m using npm run generate, not yarn)
On my project, for example, I had a component with an object referencing an svg file in the assets directory, alongside a video with a <source> referencing a file in the public directory. That component was then present on the main page. Generation did as it should and added it to the page – and also correctly created and prepended the component script and images with the correct baseUrl, but did not do so with the video or images referenced by the component.
The only thing I may suggest is playing around with the ssr option and trying with both true and false. So yeah, it’s a little weird.
Sorry that’s not much help! I ended up giving up completely and just using a custom domain–I suspect static generation is still fairly immature as it was only added in a recent release candidate.