对项目页面使用自定义基本URL [英] Using a custom base URL for project pages
问题描述
我的个人页面和项目页面都使用Github页面/Jekyll.
我也在使用自定义域,因此类似username.github.io
的内容会重定向到mycustomdomain.com
.
I'm using Github pages/Jekyll for both my personal page as well as my project page.
I'm also using a custom domain, so something like username.github.io
redirects to mycustomdomain.com
.
由于我的项目也有一个gh-pages
分支,所以我的项目页面位于mycustomdomain.com/myproject
.
Since I also have a gh-pages
branch for my projects, my project's page lives at mycustomdomain.com/myproject
.
但是,如果可以选择该URL是什么,例如mycustomdomain.com/projects/myproject
,我更愿意.
However, I'd prefer if I could choose what this URL would be, for example, mycustomdomain.com/projects/myproject
.
是否有任何方法可以执行,而无需复制/粘贴我的username.github.io
存储库的projects
文件夹中的整个项目?
Is there any way to do this, without copy/pasting the whole project my username.github.io
repository's projects
folder?
推荐答案
应为 baseurl是什么.
- 在
_config.yml
中设置baseurl
以匹配不带主机的生产URL(例如/example
,而不是http://jekyll.github.io/example
).- 运行
jekyll serve
并转到http://localhost:4000/your_baseurl/
,用在_config.yml
中设置为baseurl
的内容替换your_baseurl
,不要忘记后面的斜杠.- 确保一切正常.
随意在您的网址前添加site.baseurl
.- 启动您的主机,看看一切也在那里!
- Set
baseurl
in your_config.yml
to match the production URL without the host (e.g./example
, nothttp://jekyll.github.io/example
).- Run
jekyll serve
and go tohttp://localhost:4000/your_baseurl/
, replacingyour_baseurl
with whatever you setbaseurl
to in your_config.yml
, and not forgetting the trailing slash.- Make sure everything works.
Feel free to prepend your urls withsite.baseurl
.- Push up to your host and see that everything works there, too!
这篇关于对项目页面使用自定义基本URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!