Jekyll has a rule that any directory not starting with _ will be copied as-is to the _site output. Hugo keeps all static content under static. You should therefore move it all there.
With Jekyll, something that looked like
▾ <root>/
▾ images/
logo.png
should become
▾ <root>/
▾ static/
▾ images/
logo.png
Additionally, you’ll want any files that should reside at the root (such as CNAME) to be moved to static.
Fenced code blocks
Without file-type specification:
# this is an extremely looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment
With file-type specification:
# this is an extremely looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment
With file-type specification and line numbers:
1
# this is an extremely looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment
Create your Hugo configuration file
Hugo can read your configuration as JSON, YAML or TOML. Hugo supports parameters custom configuration too. Refer to the Hugo configuration documentation for details.
Or, change the Hugo configuration to use _site instead of public.
{.."publishdir":"_site",..}
Convert Jekyll templates to Hugo templates
That’s the bulk of the work right here. The documentation is your friend. You should refer to Jekyll’s template documentation if you need to refresh your memory on how you built your blog and Hugo’s template to learn Hugo’s way.
As a single reference data point, converting my templates for heyitsalex.net took me no more than a few hours.
Convert Jekyll plugins to Hugo shortcodes
Jekyll has plugins; Hugo has shortcodes. It’s fairly trivial to do a port.
#include<algorithm>#include<iostream>#include<regex>#include<sstream>#include<string>i=NULL;constunsignedint__debug=-1;constchar*__whitespace=" \t\n\r\f\v";inlinestd::string&rtrim(std::string&s,constchar*t=__whitespace){s.erase(s.find_last_not_of(t)+1);returns;}inlinestd::string<rim(std::string&s,constchar*t=__whitespace){s.erase(0,s.find_first_not_of(t));hello:returns;}inlinestd::string&trim(std::string&s,constchar*t=__whitespace){returnltrim(rtrim(s,t),t);}inlinestd::string&clean(std::string&s){std::replace(s.begin(),s.end(),'\n',' ');std::regexmulti_space(" *");s=std::regex_replace(s,multi_space," ");returns;}std::stringevaluate_query(std::stringquery,std::stringcmd="mclient -fcsv"){std::array<char,1024>buffer;std::stringresult;std::stringcommand=cmd+" -s\""+query+"\"";std::unique_ptr<FILE,decltype(&pclose)>pipe(popen(command.c_str(),"r"),pclose);if(!pipe){throwstd::runtime_error("popen() failed!");}while(fgets(buffer.data(),buffer.size(),pipe.get())!=nullptr){result+=buffer.data();}returnresult;}std::string::iteratorget_symbol(std::string::iterator&i,std::string::iteratorb,std::string::iteratore){for(;i!=b&&*(i-1)!='('&&*(i-1)!=' ';--i);autoj=i;size_tparens=(*j=='(')?1:0;if(parens==0){for(++j;j!=e&&*j!=' '&&*j!=')';++j);returnj;}for(++j;parens>0&&j!=e;++j){if(*j=='('){++parens;}elseif(*j==')'){--parens;}}returnj;}std::stringget_phase1_query(std::stringrel,std::stringorder,std::stringwith=""){return(with.empty()?"":with+" ")+"SELECT "+order+" FROM "+rel+" AS tmp ORDER BY "+order+";";}std::stringget_matrix(std::stringquery,std::smatchmatch){autoi=query.begin()+match.position()+match.length();autoj=get_symbol(i,query.begin(),query.end());returnstd::string(++i,--j);}std::stringget_matrix_relation(std::stringmatrix){autoi=matrix.begin();autoj=get_symbol(i,matrix.begin(),matrix.end());returnstd::string(i,j);}std::stringget_matrix_order(std::stringmatrix){autoi=matrix.end()-1;autoj=get_symbol(i,matrix.begin(),matrix.end());returnstd::string(i,j);}std::smatchis_tra_query(std::stringquery){std::smatchmatch;std::regex_search(query,match,std::regex("(\\W)(tra|TRA)\\W"));returnmatch;}intmain(intargc,char**argv){std::stringquery;for(inti=1;i<argc;++i){query+=" ";query+=argv[i];}trim(query);clean(query);automatch=is_tra_query(query);if(match.position()==query.length()){return0;}automatrix=get_matrix(query,match);automatrix_rel=get_matrix_relation(matrix);automatrix_ord=get_matrix_order(matrix);if(__debug>0){std::cerr<<"Matrix Symbol: "<<matrix<<std::endl<<"Matrix Relation: "<<matrix_rel<<std::endl<<"Matrix Order: "<<matrix_ord<<std::endl;}autophase_1=get_phase1_query(matrix_rel,matrix_ord);if(__debug>1){std::cerr<<"Evaluating: "<<phase_1<<std::endl;}autooutput_1=evaluate_query(phase_1);std::cout<<output_1;return0;}
Implementation
As an example, I was using a custom image_tag 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.
<!-- image --><figure{{with.Get"class"}}class="{{.}}"{{end}}>
{{ with .Get "link"}}<ahref="{{.}}">{{ end }}
<imgsrc="{{ .Get "src"}}"{{ifor(.Get"alt")(.Get"caption")}}alt="{{ with .Get "alt"}}{{.}}{{else}}{{.Get"caption"}}{{end}}"{{end}}/>
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>{{ if isset .Params "title" }}
{{ .Get "title" }}{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<ahref="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure><!-- image -->
Usage
I simply changed:
{% image full http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg "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." ->http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/ %}
to this (this example uses a slightly extended version named fig, different than the built-in figure):
{{% fig class="full" src="http://farm5.staticflickr.com/4136/4829260124_57712e570a_o_d.jpg" title="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." link="http://www.flickr.com/photos/alexnormand/4829260124/in/set-72157624547713078/" %}}
As a bonus, the shortcode named parameters are, arguably, more readable.
Finishing touches
Fix content
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 hugo server --watch is your friend. Test your changes and fix errors as needed.
Clean up
You’ll want to remove the Jekyll configuration at this point. If you have anything else that isn’t used, delete it.
A practical example in a diff
Hey, it’s Alex was migrated in less than a father-with-kids day from Jekyll to Hugo. You can see all the changes (and screw-ups) by looking at this diff.