github 页面上的 jekyll 有不正确的 src(例如 "http://localhost:4000/assets/js/scripts.min.js")

jekyll on github page has incorrect src (eg. "http://localhost:4000/assets/js/scripts.min.js")

我的项目:https://github.com/sebastian3495/sebastian3495.github.io 我的网站(当前显示未呈现 css):https://sebastian3495.github.io/

如何让所有链接都指向我的 github 项目而不是本地主机?

我错过了什么?我是 jekyll 的新手,网络开发不是我的强项,所以请多多包涵。

编辑:我的配置文件已更新

_config.yml

title:            Blog Title
description:      Describe your website here.

# put your disqus here
remote_theme: aron-bordin/neo-hpstr-jekyll-theme
disqus_shortname:
reading_time:     true # if true, shows the estimated reading time for a post
words_per_minute: 200
logo:             images/logo.png # logo visible in the topbar
excerpt_separator: <!--more-->
url: https://sebastian3495.github.io




# draw your top menu here
# each item must have a title and a url.
#   To list post categories. use type: 'categories'
#   To create sub categories. add a submenu item
# See the example
menu:
  - title: 'Home'
    url: '/'
  - title: 'Fork'
    url: 'http://github.com/aron-bordin/neo-hpstr-jekyll-theme'
  - title: 'Install'
    url: 'http://github.com/aron-bordin/neo-hpstr-jekyll-theme#installation'
  - title: 'Tags'
    url: '/tags'
  - title: 'Categories'
    url: '/categories'
    type: 'categories'
  - title: 'Favorites'
    url: '#'
    submenu:
      - title: 'Code Highlighter'
        url: '/intro/code-highlighting-post/'
      - title: 'Sample Post'
        url: '/intro/sample-post/'

# Owner/author information
owner:
  name:           Sebastian Nielsen
  site:           http://aronbordin.com
  avatar:         images/avatar.jpg
  bio:            "TEsting stuff off! . :D . It shouldn't be super long but a good two sentences or two should suffice."
  email:          you@email.com
  # Twitter nick for use in Twitter cards and follow button.
  twitter: aron_bordin # if no twitter in this config, the twitter follow button will be removed
  # GitHub nick for use in follow button in author block.
  github: aron-bordin

# Twitter account associated with the site if different from owner/author twitter account.
# Used in Twitter cards.
twitter:

# Social networking links used in author block underneath posts. Update and remove as you like.
social:
  - title: "github"
    url: "https://github.com/aron-bordin"
  - title: "linkedin"
    url: "https://br.linkedin.com/in/aronbordin"
  - title: "youtube"
    url: "https://www.youtube.com/channel/UCfnSek-9HPWOx5e2pH7VFgg"

# Background image to be tiled on all pages
background:

# Analytics and webmaster tools stuff goes here
google_analytics:
google_verify:
# https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here
bing_verify:

# http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone:    America/New_York
locale:      en_US
future:      true
highlighter: rouge
markdown:    kramdown
sass:
  sass_dir: _sass
  style: compressed

# https://github.com/mojombo/jekyll/wiki/Permalinks
permalink:   /:categories/:title/

# Amount of post to show on home page
paginate: 5

# if true, shows the floatting share buttons
float_share: true

# Octopress
# Default extensions
post_ext: md
page_ext: md
# Found in _templates/
post_layout: post
page_layout: page
# Format titles with titlecase?
titlecase: true

include: [".htaccess", "C:/Users/sebas/Documents/GitHub/Sebastian_Nielsen_Blog/_includes"]
exclude: ["demo/*", "lib", "config.rb", "Capfile", "config", "Gemfile", "Gemfile.lock", "README.md", "LICENSE", "log", "Rakefile", "Rakefile.rb", "tmp", "less", "*.sublime-project", "*.sublime-workspace", "test", "spec", "Gruntfile.js", "package.json", "node_modules"]
plugins: ["jekyll-paginate", "jekyll-remote-theme"]
theme: neo-hpstr-jekyll-theme

由于您使用的是 third-party 主题,我知道您是按照说明先在本地 运行 jekyll build 然后上传了 ./_site 目录的内容.

这里的问题是,当您在本地 build 时,最新版本的 Jekyll 会自动将 url 键设置为 http://localhost:4000

您有两个基本选择:

  1. 要在 GitHub 页面上同时使用 third-party 主题和 third-party 插件,您需要通过更改 JEKYLL_ENV 环境在本地构建站点至 production(或除 development 之外的任何其他

    JEKLL_ENV=production bundle exec jekyll build
    

    (在 Windows,你需要先 运行 set JEKLL_ENV=production 然后是 jekyll 咒语。

  2. 要使用只需要官方插件的 third-party 主题,并且 theme-repo 本身也在 GitHub 上托管,您可以使用 remote_theme 功能(默认包含在 gem "github-pages" 的最新版本中):

    # _config.yml
    
    remote_theme: aron-bordin/neo-hpstr-jekyll-theme
    

    参考:https://github.com/benbalter/jekyll-remote-theme 了解有关 jekyll-remote-theme 插件使用的详细信息。

在推送本地生成的代码时,您需要:

  • _config.yml中设置url: https://sebastian3495.github.io

  • 运行一个bundle exec jekyll build

  • 将生成的代码推送到github。