question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Way of specifying base URL for static site generation (github pages)

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Oct 7, 2022

There is a pending PR to resolve that: https://github.com/nuxt/framework/pull/7984

1reaction
WiIIiam278commented, Oct 7, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

About GitHub Pages
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs...
Read more >
Deploying as a GitHub Project Page based site needs ...
Create images at /blog/images/fred.png and static/images/fred-uml.png . Run hugo. Assuming baseURL = "https://user.
Read more >
site.baseurl behaviour specific to GitHub Pages · Issue #350
The problem is that an empty baseurl is overridden on GitHub Pages, but not a non-empty one. The behaviour is not exactly the...
Read more >
When using a baseURL with path, links to static resources don ...
High-Level Scenario. Given I use a baseURL with path, i.e. https://mywebsite.net/blog. And I build my site using hugo or hugo server
Read more >
Changing the visibility of your GitHub Pages site
Changing the visibility of your GitHub Pages site · On GitHub Enterprise Cloud, navigate to your site's repository. · Under your repository name,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found