Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.html « migrate-from-jekyll « post « public « exampleSite - github.com/ExchangeRate-API/strange-case.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a86e66b156b9c4e3ca5d064cdae14c9caaeaad68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html >
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="generator" content="Hugo 0.53" />
	
	<title>Migrate to Hugo from Jekyll - A Hugo Theme built with Bootstrap</title>

	
	<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
	<link href="https://gohugo.io//css/bootstrap.min.css" rel="stylesheet">
	<link href="https://gohugo.io//css/strange-case.css" rel="stylesheet">
	

	
	
	<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body class="scheme-darkbrown">

	<div class="container-fluid">
		<div class="row">
			<div class="col-sm-4 col-md-3 col-lg-3 sidebar">

			
	<div class="sidebar-content">

		<a href="https://gohugo.io/"><h1>Hugo Themes</h1></a>
		<p>A Hugo Theme built with Bootstrap</p>

		
		<div class="sidebar-freetext">
			<p>A optional paragraph of free text. Set to blank in config.toml to clear...</p>
		</div>
		

		<ul class="sidebar-menus">
			
				<li>&#187; <a href="https://gohugo.io/post/goisforlovers/">(Hu)go Template Primer</a> </li>
			
				<li>&#187; <a href="https://gohugo.io/about/">About Hugo</a> </li>
			
				<li>&#187; <a href="http://getbootstrap.com">Bootstrap</a> <span class='glyphicon glyphicon-ok'></span></li>
			
				<li>&#187; <a href="https://gohugo.io/post/hugoisforlovers/">Getting Started with Hugo</a> </li>
			
				<li>&#187; <a href="http://gohugo.io">Hugo</a> <span class='glyphicon glyphicon-fire'></span></li>
			
				<li>&#187; <a href="">tutorials</a> </li>
			
		</ul>

		<div class="sidebar-recent hidden-xs">
			<p>Recent Posts:</p>
			<ul>
				
				<li><a href="https://gohugo.io/post/creating-a-new-theme/">Creating a New Theme</a></li>
				
				<li><a href="https://gohugo.io/post/migrate-from-jekyll/">Migrate to Hugo from Jekyll</a></li>
				
				<li><a href="https://gohugo.io/about/">About Hugo</a></li>
				
				<li><a href="https://gohugo.io/post/goisforlovers/">(Hu)go Template Primer</a></li>
				
				<li><a href="https://gohugo.io/post/hugoisforlovers/">Getting Started with Hugo</a></li>
				
			</ul>
		</div>

		<p class="copyright">&copy; 2019. All rights reserved. </p>
		<p class="attr">Powered by <a href="http://gohugo.io">Hugo</a> &amp; <a href="https://github.com/ExchangeRate-API/strange-case">Strange Case</a> (inspired by <a href="https://github.com/poole/hyde">Hyde</a>).</p>

	</div>


			</div>
			<div class="col-sm-7 col-sm-offset-4 col-md-6 col-md-offset-3 col-lg-5 col-lg-offset-3 content">

				<div class="post">

					<div class="post-heading">
						<h1>Migrate to Hugo from Jekyll</h1>
						<span class="post-date"><a href="https://gohugo.io/post/migrate-from-jekyll/"># Mar 10, 2014</a></span>
					</div>

					

<h2 id="move-static-content-to-static">Move static content to <code>static</code></h2>

<p>Jekyll has a rule that any directory not starting with <code>_</code> will be copied as-is to the <code>_site</code> output. Hugo keeps all static content under <code>static</code>. You should therefore move it all there.
With Jekyll, something that looked like</p>

<pre><code>▾ &lt;root&gt;/
    ▾ images/
        logo.png
</code></pre>

<p>should become</p>

<pre><code>▾ &lt;root&gt;/
    ▾ static/
        ▾ images/
            logo.png
</code></pre>

<p>Additionally, you&rsquo;ll want any files that should reside at the root (such as <code>CNAME</code>) to be moved to <code>static</code>.</p>

<h2 id="create-your-hugo-configuration-file">Create your Hugo configuration file</h2>

<p>Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the <a href="https://gohugo.io/overview/configuration/">Hugo configuration documentation</a> for details.</p>

<h2 id="set-your-configuration-publish-folder-to-site">Set your configuration publish folder to <code>_site</code></h2>

<p>The default is for Jekyll to publish to <code>_site</code> and for Hugo to publish to <code>public</code>. If, like me, you have <a href="http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html"><code>_site</code> mapped to a git submodule on the <code>gh-pages</code> branch</a>, you&rsquo;ll want to do one of two alternatives:</p>

<ol>
<li><p>Change your submodule to point to map <code>gh-pages</code> to public instead of <code>_site</code> (recommended).</p>

<pre><code>git submodule deinit _site
git rm _site
git submodule add -b gh-pages git@github.com:your-username/your-repo.git public
</code></pre></li>

<li><p>Or, change the Hugo configuration to use <code>_site</code> instead of <code>public</code>.</p>

<pre><code>{
    ..
    &quot;publishdir&quot;: &quot;_site&quot;,
    ..
}
</code></pre></li>
</ol>

<h2 id="convert-jekyll-templates-to-hugo-templates">Convert Jekyll templates to Hugo templates</h2>

<p>That&rsquo;s the bulk of the work right here. The documentation is your friend. You should refer to <a href="http://jekyllrb.com/docs/templates/">Jekyll&rsquo;s template documentation</a> if you need to refresh your memory on how you built your blog and <a href="https://gohugo.io/layout/templates/">Hugo&rsquo;s template</a> to learn Hugo&rsquo;s way.</p>

<p>As a single reference data point, converting my templates for <a href="http://heyitsalex.net/">heyitsalex.net</a> took me no more than a few hours.</p>

<h2 id="convert-jekyll-plugins-to-hugo-shortcodes">Convert Jekyll plugins to Hugo shortcodes</h2>

<p>Jekyll has <a href="http://jekyllrb.com/docs/plugins/">plugins</a>; Hugo has <a href="https://gohugo.io/doc/shortcodes/">shortcodes</a>. It&rsquo;s fairly trivial to do a port.</p>

<h3 id="implementation">Implementation</h3>

<p>As an example, I was using a custom <a href="https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb"><code>image_tag</code></a> plugin to generate figures with caption when running Jekyll. As I read about shortcodes, I found Hugo had a nice built-in shortcode that does exactly the same thing.</p>

<p>Jekyll&rsquo;s plugin:</p>

<pre><code>module Jekyll
  class ImageTag &lt; Liquid::Tag
    @url = nil
    @caption = nil
    @class = nil
    @link = nil
    // Patterns
    IMAGE_URL_WITH_CLASS_AND_CAPTION =
    IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK = /(\w+)(\s+)((https?:\/\/|\/)(\S+))(\s+)&quot;(.*?)&quot;(\s+)-&gt;((https?:\/\/|\/)(\S+))(\s*)/i
    IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)&quot;(.*?)&quot;/i
    IMAGE_URL_WITH_CLASS = /(\w+)(\s+)((https?:\/\/|\/)(\S+))/i
    IMAGE_URL = /((https?:\/\/|\/)(\S+))/i
    def initialize(tag_name, markup, tokens)
      super
      if markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION_AND_LINK
        @class   = $1
        @url     = $3
        @caption = $7
        @link = $9
      elsif markup =~ IMAGE_URL_WITH_CLASS_AND_CAPTION
        @class   = $1
        @url     = $3
        @caption = $7
      elsif markup =~ IMAGE_URL_WITH_CAPTION
        @url     = $1
        @caption = $5
      elsif markup =~ IMAGE_URL_WITH_CLASS
        @class = $1
        @url   = $3
      elsif markup =~ IMAGE_URL
        @url = $1
      end
    end
    def render(context)
      if @class
        source = &quot;&lt;figure class='#{@class}'&gt;&quot;
      else
        source = &quot;&lt;figure&gt;&quot;
      end
      if @link
        source += &quot;&lt;a href=\&quot;#{@link}\&quot;&gt;&quot;
      end
      source += &quot;&lt;img src=\&quot;#{@url}\&quot;&gt;&quot;
      if @link
        source += &quot;&lt;/a&gt;&quot;
      end
      source += &quot;&lt;figcaption&gt;#{@caption}&lt;/figcaption&gt;&quot; if @caption
      source += &quot;&lt;/figure&gt;&quot;
      source
    end
  end
end
Liquid::Template.register_tag('image', Jekyll::ImageTag)
</code></pre>

<p>is written as this Hugo shortcode:</p>

<pre><code>&lt;!-- image --&gt;
&lt;figure {{ with .Get &quot;class&quot; }}class=&quot;{{.}}&quot;{{ end }}&gt;
    {{ with .Get &quot;link&quot;}}&lt;a href=&quot;{{.}}&quot;&gt;{{ end }}
        &lt;img src=&quot;{{ .Get &quot;src&quot; }}&quot; {{ if or (.Get &quot;alt&quot;) (.Get &quot;caption&quot;) }}alt=&quot;{{ with .Get &quot;alt&quot;}}{{.}}{{else}}{{ .Get &quot;caption&quot; }}{{ end }}&quot;{{ end }} /&gt;
    {{ if .Get &quot;link&quot;}}&lt;/a&gt;{{ end }}
    {{ if or (or (.Get &quot;title&quot;) (.Get &quot;caption&quot;)) (.Get &quot;attr&quot;)}}
    &lt;figcaption&gt;{{ if isset .Params &quot;title&quot; }}
        {{ .Get &quot;title&quot; }}{{ end }}
        {{ if or (.Get &quot;caption&quot;) (.Get &quot;attr&quot;)}}&lt;p&gt;
        {{ .Get &quot;caption&quot; }}
        {{ with .Get &quot;attrlink&quot;}}&lt;a href=&quot;{{.}}&quot;&gt; {{ end }}
            {{ .Get &quot;attr&quot; }}
        {{ if .Get &quot;attrlink&quot;}}&lt;/a&gt; {{ end }}
        &lt;/p&gt; {{ end }}
    &lt;/figcaption&gt;
    {{ end }}
&lt;/figure&gt;
&lt;!-- image --&gt;
</code></pre>

<h3 id="usage">Usage</h3>

<p>I simply changed:</p>

<pre><code>{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg &quot;One of my favorite touristy-type photos. I secretly waited for the good light while we were &quot;having fun&quot; and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing.&quot; -&gt;http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
</code></pre>

<p>to this (this example uses a slightly extended version named <code>fig</code>, different than the built-in <code>figure</code>):</p>

<pre><code>{{% fig class=&quot;full&quot; src=&quot;http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg&quot; title=&quot;One of my favorite touristy-type photos. I secretly waited for the good light while we were having fun and took this. Only regret: a stupid pole in the top-left corner of the frame I had to clumsily get rid of at post-processing.&quot; link=&quot;http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/&quot; %}}
</code></pre>

<p>As a bonus, the shortcode named parameters are, arguably, more readable.</p>

<h2 id="finishing-touches">Finishing touches</h2>

<h3 id="fix-content">Fix content</h3>

<p>Depending on the amount of customization that was done with each post with Jekyll, this step will require more or less effort. There are no hard and fast rules here except that <code>hugo server --watch</code> is your friend. Test your changes and fix errors as needed.</p>

<h3 id="clean-up">Clean up</h3>

<p>You&rsquo;ll want to remove the Jekyll configuration at this point. If you have anything else that isn&rsquo;t used, delete it.</p>

<h2 id="a-practical-example-in-a-diff">A practical example in a diff</h2>

<p><a href="http://heyitsalex.net/">Hey, it&rsquo;s Alex</a> was migrated in less than a <em>father-with-kids day</em> from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this <a href="https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610">diff</a>.</p>


				</div>

			</div>
			<div class="col-sm-1 col-md-3 col-md-4">
			</div>
		</div>
	</div>







<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<script src="https://gohugo.io//js/bootstrap.min.js"></script>

</body>
</html>