Github 页面重定向仅在本地有效,但在远程 Github 服务器上无效(得到 404)
Github Pages redirect only works locally, but not on the remote Github server (got 404)
当我点击 Github 页面右侧的标签时,它总是给我一个 404 页面。但是,当我在本地预览时,重定向似乎工作得很好:
不知道是不是和我的_config.yml
有关。我尝试了不同的 url 和 baseurl 字符串,但仍然无法解析它。
(注:此主题取自Chirpy)
谢谢!
我的一部分 config.yml
:
title: Changyu Yan
url: 'https://changyuyan.github.io'
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: ''
timezone: America/Los_Angeles
google_analytics:
id: ''
pv:
# The Google Analytics pageviews switch.
# DO NOT enable it unless you know how to deploy the Google Analytics superProxy.
enabled: false
# the next options only valid when `google_analytics.pv` is enabled.
proxy_url: ''
proxy_endpoint: ''
cache: false # pv data local cache, good for the users from GFW area.
# boolean type, the global switch for ToC in posts.
toc: true
paginate: 10
kramdown:
syntax_highlighter: rouge
syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options
css_class: highlight
# default_lang: console
span:
line_numbers: false
block:
line_numbers: true
start_line: 1
# DO NOT change this unless you're a Pro user on Jekyll and Web development,
# or you think you're smart enough to change other relevant URLs within this template.
permalink: /posts/:title/
collections:
tabs:
output: true
sort_by: order
defaults:
-
scope:
path: '' # An empty string here means all files in the project
type: posts
values:
layout: post
comments: true # Enable comments in posts.
toc: true # Display TOC column in posts.
breadcrumb:
-
label: Posts
url: /
-
scope:
path: _drafts
values:
comments: false
-
scope:
path: index.html
values:
breadcrumb:
-
label: Posts
-
scope:
path: tags
values:
breadcrumb:
-
label: Home
url: /
-
label: Tags
url: /tabs/tags/
-
scope:
path: categories
values:
breadcrumb:
-
label: Home
url: /
-
label: Categories
url: /tabs/categories/
-
scope:
path: ''
type: tabs # see `site.collections`
values:
layout: page
dynamic_title: true # Hide title in mobile screens.
breadcrumb:
-
label: Home
url: /
sass:
sass_dir: /assets/css
style: compressed
compress_html:
clippings: all
comments: all
endings: all
profile: false
blanklines: false
ignore:
envs: []
exclude:
- vendor
- Gemfile.lock
- Gemfile
- tools
- docs
- README.md
- LICENSE
jekyll-archives:
enabled: [categories, tags]
layouts:
category: category
tag: tag
permalinks:
tag: /tags/:name/
category: /categories/:name/
在 _config.yml
的顶部附近,根据说明将 baseurl
设置为项目存储库的名称:
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: '/changyuyan.github.io'
档案在本地工作,而不是在 GitHub 页面上工作,因为 jekyll-archives gem 是 not supported in GitHub Pages. You can see in the notes for Chirpy, under Deploy on GitHub Pages, an option for using GitHub Actions. This should allow you to run unsupported plugins (there is a good tutorial by Aneejian)。
另一种选择是手动构建所有标签页。您需要创建一个 tag
目录并在其中创建所有标记文件 (software-engineering.html)。在那些你会 运行 那个标签的 for
循环。您有几个选择:
{% for post in site.tags.software-engineering %}
或
{% for post in site.posts | where: 'tag', 'software-engineering' %}
还有其他可能更适合您的用例。
根据 baseurl
的讨论,如果您不使用项目目录,则不需要。如果你想要 https://changyuyan.github.io/blog/tags/software-engineering/,你需要添加 baseurl: '/blog
...但它看起来不像你想要的。
当我点击 Github 页面右侧的标签时,它总是给我一个 404 页面。但是,当我在本地预览时,重定向似乎工作得很好:
不知道是不是和我的_config.yml
有关。我尝试了不同的 url 和 baseurl 字符串,但仍然无法解析它。
(注:此主题取自Chirpy)
谢谢!
我的一部分 config.yml
:
title: Changyu Yan
url: 'https://changyuyan.github.io'
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: ''
timezone: America/Los_Angeles
google_analytics:
id: ''
pv:
# The Google Analytics pageviews switch.
# DO NOT enable it unless you know how to deploy the Google Analytics superProxy.
enabled: false
# the next options only valid when `google_analytics.pv` is enabled.
proxy_url: ''
proxy_endpoint: ''
cache: false # pv data local cache, good for the users from GFW area.
# boolean type, the global switch for ToC in posts.
toc: true
paginate: 10
kramdown:
syntax_highlighter: rouge
syntax_highlighter_opts: # Rouge Options › https://github.com/jneen/rouge#full-options
css_class: highlight
# default_lang: console
span:
line_numbers: false
block:
line_numbers: true
start_line: 1
# DO NOT change this unless you're a Pro user on Jekyll and Web development,
# or you think you're smart enough to change other relevant URLs within this template.
permalink: /posts/:title/
collections:
tabs:
output: true
sort_by: order
defaults:
-
scope:
path: '' # An empty string here means all files in the project
type: posts
values:
layout: post
comments: true # Enable comments in posts.
toc: true # Display TOC column in posts.
breadcrumb:
-
label: Posts
url: /
-
scope:
path: _drafts
values:
comments: false
-
scope:
path: index.html
values:
breadcrumb:
-
label: Posts
-
scope:
path: tags
values:
breadcrumb:
-
label: Home
url: /
-
label: Tags
url: /tabs/tags/
-
scope:
path: categories
values:
breadcrumb:
-
label: Home
url: /
-
label: Categories
url: /tabs/categories/
-
scope:
path: ''
type: tabs # see `site.collections`
values:
layout: page
dynamic_title: true # Hide title in mobile screens.
breadcrumb:
-
label: Home
url: /
sass:
sass_dir: /assets/css
style: compressed
compress_html:
clippings: all
comments: all
endings: all
profile: false
blanklines: false
ignore:
envs: []
exclude:
- vendor
- Gemfile.lock
- Gemfile
- tools
- docs
- README.md
- LICENSE
jekyll-archives:
enabled: [categories, tags]
layouts:
category: category
tag: tag
permalinks:
tag: /tags/:name/
category: /categories/:name/
在 _config.yml
的顶部附近,根据说明将 baseurl
设置为项目存储库的名称:
# Only if your site type is GitHub Project sites and doesn't have a custom domain,
# change below value to '/projectname'.
baseurl: '/changyuyan.github.io'
档案在本地工作,而不是在 GitHub 页面上工作,因为 jekyll-archives gem 是 not supported in GitHub Pages. You can see in the notes for Chirpy, under Deploy on GitHub Pages, an option for using GitHub Actions. This should allow you to run unsupported plugins (there is a good tutorial by Aneejian)。
另一种选择是手动构建所有标签页。您需要创建一个 tag
目录并在其中创建所有标记文件 (software-engineering.html)。在那些你会 运行 那个标签的 for
循环。您有几个选择:
{% for post in site.tags.software-engineering %}
或
{% for post in site.posts | where: 'tag', 'software-engineering' %}
还有其他可能更适合您的用例。
根据 baseurl
的讨论,如果您不使用项目目录,则不需要。如果你想要 https://changyuyan.github.io/blog/tags/software-engineering/,你需要添加 baseurl: '/blog
...但它看起来不像你想要的。