对项目页面使用自定义基本URL [英] Using a custom base URL for project pages

查看:39
本文介绍了对项目页面使用自定义基本URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的个人页面和项目页面都使用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, not http://jekyll.github.io/example).
  • Run jekyll serve and go to http://localhost:4000/your_baseurl/, replacing your_baseurl with whatever you set baseurl to in your _config.yml, and not forgetting the trailing slash.
  • Make sure everything works.
    Feel free to prepend your urls with site.baseurl.
  • Push up to your host and see that everything works there, too!

这篇关于对项目页面使用自定义基本URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆