You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jekyll部署GitHub Pages后资源路径指向localhost问题求助

Hey there! As someone who’s fumbled through Jekyll’s config quirks as a beginner, let’s walk through how to get those links pointing to your live GitHub Pages site instead of localhost. Since you mentioned updating _config.yml, let’s start by verifying those settings, then cover the other common gotchas that trip up new users.

1. Double-Check Your _config.yml Core Settings

The two most critical values here are url and baseurl—make sure they’re configured perfectly for your repo:

  • url: This needs to be your full live site URL. For your case, that’s https://sebastian3495.github.io
  • baseurl: Since your repo is the special user/organization site (named sebastian3495.github.io), this should be an empty string: ""

Your config should have lines like this:

url: "https://sebastian3495.github.io"
baseurl: ""

If you previously set baseurl to something like /sebastian3495.github.io, that would break links on the live site—so empty is the right call here.

2. Stop Hardcoding Links—Use Jekyll’s Site Variables

The #1 mistake new Jekyll users make is writing hardcoded links like http://localhost:4000/about in templates or markdown files. Instead, always build links using site.url and site.baseurl to ensure they work both locally and on your live site.

Examples of correct link formatting:

  • In HTML templates (like header.html or footer.html):
    <a href="{{ site.url }}{{ site.baseurl }}/about">About</a>
    
  • In markdown posts/pages:
    [My About Page]({{ site.url }}{{ site.baseurl }}/about)
    

Do a full search across your _layouts, _includes, and markdown files to replace any leftover localhost links—they’re easy to miss!

3. Refresh Jekyll’s Cache & Restart Your Server

Jekyll caches old config values and generated files, so even if you updated _config.yml, the old settings might still be loaded. Fix this with these quick steps:

  1. Stop your running local server (press Ctrl+C in your terminal)
  2. Clear cached files:
    bundle exec jekyll clean
    
  3. Restart the server to generate fresh files with your updated config:
    bundle exec jekyll serve
    

Now when you view your local site, links should show your GitHub Pages URL instead of localhost.

4. Verify Deployment to GitHub Pages

After pushing your updated config and templates to GitHub, give Pages a minute to rebuild your site. Once it’s done, check the live site—all links should now point to https://sebastian3495.github.io instead of localhost.

If you still see issues, double-check for any hidden hardcoded links (they sometimes hide in _config.yml’s permalink settings or custom template variables). A full repo search for localhost will help you catch any stragglers.

内容的提问来源于stack exchange,提问作者John Nielsen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:02:19