Octopress部署到项目[gh-pages] CSS JS [英] Octopress deploy to project[gh-pages] css js
问题描述
我想在我的github项目之一的gh-pages分支上设置octopress博客.我遵循octopress部署文档中的指南.我的项目存储库URL是标准的:https://github.com/my_user_name/project_name
I want to setup octopress blog on gh-pages branch of one of my github projects. I follow guidelines from the octopress deployment docs. My project repository url is standard: https://github.com/my_user_name/project_name
我遵循两种情况,但都无法以某种方式起作用.
I follow two scenarios by neither works in some way.
我调用rake setup_github_pages
并为其提供存储库位置:
git@github.com:my_user_name/project_name.git
效果很好,并且在我的项目存储库中创建了gh-pages分支.
I invoke rake setup_github_pages
and supply it with repository location:
git@github.com:my_user_name/project_name.git
This works well and gh-pages branch is created in my project repo.
我不更改_config.yml
中的Jekill设置,尤其是root:
为空.
rake generate && preview
工作正常.我将站点加载到local host:4000
上.
CSS和JS已正确加载.
I do not change Jekill setup in _config.yml
, in particular root:
is empty.
rake generate && preview
work well. I load the site on local host:4000
.
Css and js are loaded correctly.
现在我部署站点:rake generate && deploy
我将octopress博客加载为:http://my_user_name.github.io/project_name/
Now I deploy the site: rake generate && deploy
I load octopress blog as: http://my_user_name.github.io/project_name/
问题:博客加载时没有screen.css
.此外,我看到以下有关javascript的错误:
Problem: the blog loads without screen.css
. Moreover, I see following errors for javascript:
[错误]无法加载资源:服务器以404(未找到)状态响应(jquery.fancybox.pack.js,第0行)
http://my_user_name.github.io/javascripts/jquery.fancybox.pack.js
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery.fancybox.pack.js, line 0)
http://my_user_name.github.io/javascripts/jquery.fancybox.pack.js
方案2:
与上述相同,但我更改了_config.yml
,尤其是将 root: /project_name
设置为我的项目存储库的名称.
Scenario 2:
Same as above, but I change _config.yml
, in particular is set root: /project_name
to the name of my project repo.
rake generate && preview
我在local host:4000
上加载了站点,但现在出现错误,但是在本地计算机上:
rake generate && preview
I load the site on local host:4000
and now I get errors, but on my local machine:
对于screen.css
,jquery.fancybox.pack.js
和
[错误]无法加载资源:服务器响应状态为404(未找到)(slash.js,第0行)
local host:4000/project_name/javascripts/slash.js
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (slash.js, line 0)
local host:4000/project_name/javascripts/slash.js
现在我部署站点:rake generate && deploy
CSS正确加载,而错误控制台显示我不是在项目路径中而是在主仓库路径中搜索javascript:
Now I deploy the site: rake generate && deploy
Css loads correctly, while error console shows that I searches for javascript not in my project path, but at my main repo path:
[错误]无法加载资源:服务器以404(未找到)状态响应(jquery.fancybox.pack.js,第0行)
http://my_user_name.github.io/javascripts/jquery.fancybox.pack.js
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery.fancybox.pack.js, line 0)
http://my_user_name.github.io/javascripts/jquery.fancybox.pack.js
请指教,我在做什么错了?
Please advice, what am I doing wrong?
我不正确地使用rake setup_github_pages
吗?
我是否在_config.yml
中错误地设置了root
?
还是有一些其他设置信息需要解决?
Do I use rake setup_github_pages
incorrectly?
Do I setup root
in _config.yml
incorrectly?
Or is there some additional setup information that has to be resolved?
推荐答案
正在回答自己.这里有两个问题.
Answering myself. There are two issues here.
首先,rake set_root_dir[dir_name]
.这在StackOverflow上从未提及:
除了http://octopress.org/docs/deploying/github/
中指定的内容外,还指定了一个单独的步骤,用于将项目部署到Github的项目页面(而非用户页面).不幸的是,在该文档中没有直接看到它.
步骤 http://octopress.org/docs/deploying/subdir/要求运行Rakefile
和config.rb
的一些修改.
这样可以正确解析在Github的项目页面([gh-pages]分支)或子目录中发布的octopress的路径.
First, rake set_root_dir[dir_name]
. This has never been mentioned on StackOverflow:
There is a separate step specified for deploying projects to Github's project pages (not user pages) in addition to what is specified in http://octopress.org/docs/deploying/github/
. Unfortunately it's not directly seen in that documentation.
The step http://octopress.org/docs/deploying/subdir/ requires running rake set_root_dir[project_name]
and a few modifications to Rakefile
and config.rb
.
This resolves the paths correctly for octopress published in Github's project pages ([gh-pages] branch) or in subdirectories.
第二个问题似乎与在将octopress部署到Github的项目页面(子目录)时必须解决自定义主题的资源路径(在我的情况下为jquery.fancybox.pack.js
)有关.
必须检查自定义主题的字体,css和js的路径也已调整为{{root_url}}.
The second issue seems to be related to how the paths to resources (jquery.fancybox.pack.js
in my case) have to be resolved for custom themes, when octopress is deployed to Github's project pages (subdirectory).
One has to check that a custom theme has paths adjusted to {{ root_url }} for fonts, css and js as well.
这篇关于Octopress部署到项目[gh-pages] CSS JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!