在现有的Jekyll安装中切换主题 [英] Switch theme in an existing Jekyll installation

查看:474
本文介绍了在现有的Jekyll安装中切换主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jekyll有很多主题,例如 https://github.com/jekyll/jekyll/wiki/Themes .

There are many themes for Jekyll, e.g. https://github.com/jekyll/jekyll/wiki/Themes.

在现有的Jekyll安装中切换到新主题的最简单方法是什么?

What is the easiest way to switch to a new theme in an EXISTING Jekyll installation?

推荐答案

可以通过派生新主题然后手动复制和粘贴CSS,JS, _includes_layouts和您可能需要的其他文件中的HTML,这可能不是一个好主意,因为您最终混搭了旧资源和新资源,它们的名称可能不相同,但是在这种情况下(例如,您没有覆盖帖子引用的旧样式表),将导致混合CSS样式,您必须对其进行调试并慢慢修复.

While you could migrate to an existing installation by forking a new theme and then manually copy and pasting over resources like CSS, JS, HTML in the _includes, _layouts and other files you may need, this probably isn't a great idea as you end up having a mash up of old and new resources, which may not be of the same name, but in the scenario that they are (for example you didn't overwrite an old stylesheet that your post references), it will cause mixed up CSS styles that you'll have to debug and slowly fix.

由于我假设您已使用Git安装了Jekyll (如果不是,则应该这样做),因此可以创建一个名为new-theme的分支,然后从master作为工作分支. (一种简单的方法是,如果您不想处理Git分支,则只需复制整个Jekyll安装并将其粘贴为old-Jekyll-install到其他位置(但实际上,您应该这样做.

Since I'm assuming you have a Jekyll install with Git (if you don't you really should), you could create a branch called new-theme and switch to that branch from the master as the working branch. (A simpleton way of having something like this is to just copy your entire Jekyll install and paste it elsewhere as old-Jekyll-install if you don't want to deal with Git branches (but really, you should. Here's a tutorial that helped me learn)

  1. 为新主题下拉文件.
  2. 手动复制_posts和您的自定义更改.
  3. 通过手动比较_config.yml并移至必要内容来移植您的_config.yml.
  4. 构建站点,然后查看丢失的内容,可能被弄乱的内容(例如,在过去,您可能添加了一些<br \>标记来分隔空格,而您不希望在新主题中使用该标记).
  5. master合并(或将其推送到生产环境)
  1. Pull down the files for the new theme.
  2. Manually copy over _posts and your customized changes.
  3. Port over your _config.yml by manually comparing them and moving over what is necessary.
  4. Build the site and see what you're missing, what might be messed up (for example in the past you might have added a few <br \> tags for spacing and you don't want that in the new theme).
  5. Merge with master (or push it to production)

话虽这么说,所有这一切都是相当手工的和痛苦的,但至少您不必处理资源冲突.这样做的缺点是您的存储库不会与主题存储库同步.因此,您将不会获得上游更新.我仍然建议您 fork 主题仓库,移植您的Jekyll网站个性化定制,然后重命名该仓库以进行生产. (这当然不再使用现有的" Jekyll安装)

That being said all this is fairly manual and a pain, but at least you won't have to deal with conflicts in resources. The downside of doing this though is that your repository won't be synced with the theme repo. So you won't get upstream updates. I would still suggest that you fork the theme repo, port over your personal customizations for your Jekyll site, and then rename that repo for production. (this would of course no longer be using the 'existing' Jekyll installation)

这篇关于在现有的Jekyll安装中切换主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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