Static resources not loading on GitHub Pages

前端 未结 3 1152
情歌与酒
情歌与酒 2021-02-02 08:44

I have created a website and am trying to host it on git hub pages. My site is available at -

http://.github.io//

相关标签:
3条回答
  • 2021-02-02 09:07

    If your project is a React app created with Create React App, set the homepage in your package.json, for example:

    "homepage": "/<project name>",
    

    If you're not using client-side routing, use this:

    "homepage": ".",
    

    See https://create-react-app.dev/docs/deployment/#building-for-relative-paths.

    0 讨论(0)
  • 2021-02-02 09:17

    The other option is to include the file .nojekyll in your top-level directory which tells github to just serve your pages with out trying to break them (this is useful if you are trying to post the oputput from sphinx which does not need any more parsing/munging/rewriting).

    relevant link

    0 讨论(0)
  • 2021-02-02 09:30

    From the documentation to setup a custom domain:

    Warning: Project pages subpaths like http://username.github.io/projectname will not be redirected to a project's custom domain.

    This means that due to the relative paths you can either have the assets on your username.github.io/project-name or on your custom domain.

    If you want them in the github one check what the documentation says about the baseurl configuration, it's at the bottom of the page, in the "Project Url Structure". It's simple you just need to add a

    baseurl: /project-name
    

    row to your _config.yml and use the {{ baseurl }} tag in your permalinks, jekyll will do the substitutions. And to test it locally just run the server with this option

    jekyll serve --baseurl ''
    

    Hope it helps :) Happy coding!

    0 讨论(0)
提交回复
热议问题