From 888b5b332b29cd7dafceb36a31db2c504f4ccc83 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Sun, 6 May 2018 12:17:20 +0900 Subject: [PATCH] Init commit --- .gitignore | 2 + .gitmodules | 3 + README.md | 4 + config.toml | 62 ++++++++++++ content/post/migrate-from-jekyll.md | 152 ++++++++++++++++++++++++++++ content/post/second-post.md | 10 ++ content/post/what-this-is.md | 12 +++ content/project/nas-101.md | 13 +++ 8 files changed, 258 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 config.toml create mode 100644 content/post/migrate-from-jekyll.md create mode 100644 content/post/second-post.md create mode 100644 content/post/what-this-is.md create mode 100644 content/project/nas-101.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..003aaef --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +themes/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7b30435 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "themes/minimal"] + path = themes/minimal + url = https://github.com/calintat/minimal.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..b103f5f --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# A new blog + +in `go` + diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..20b6b49 --- /dev/null +++ b/config.toml @@ -0,0 +1,62 @@ +baseURL = "http://sipp11.com/" +languageCode = "en-us" +title = "sipp11" +theme = "minimal" +disqusShortname = "sipp11" # delete this to disable disqus comments +googleAnalytics = "UA-3189083-1" + +[params] + author = "Sippakorn Khaimook" + #description = "sipp11 blog powered by hugo" + githubUsername = "sipp11" + accent = "#eb6090" + showBorder = true + backgroundColor = "white" + font = "Raleway" # should match the name on Google Fonts! + highlight = true + highlightStyle = "solarized-dark" + highlightLanguages = ["go", "python", "kotlin", "bash", "swift"] + +[[menu.main]] + url = "/" + name = "Home" + weight = 1 + +[[menu.main]] + url = "/post/" + name = "Posts" + weight = 2 + +[[menu.main]] + url = "/project/" + name = "Projects" + weight = 3 + +# Social icons to be shown on the right-hand side of the navigation bar +# The "name" field should match the name of the icon to be used +# The list of available icons can be found at http://fontawesome.io/icons/ + +#[[menu.icon]] +# url = "mailto:me@example.com" +# name = "envelope-o" +# weight = 1 + +[[menu.icon]] + url = "https://github.com/sipp11/" + name = "github" + weight = 2 + +[[menu.icon]] + url = "https://twitter.com/sipp11/" + name = "twitter" + weight = 3 + +#[[menu.icon]] +# url = "https://www.linkedin.com/in/sipp11/" +# name = "linkedin" +# weight = 4 + +#[[menu.icon]] +# url = "https://www.stackoverflow.com/sipp11/" +# name = "stack-overflow" +# weight = 5 diff --git a/content/post/migrate-from-jekyll.md b/content/post/migrate-from-jekyll.md new file mode 100644 index 0000000..a8c9429 --- /dev/null +++ b/content/post/migrate-from-jekyll.md @@ -0,0 +1,152 @@ +--- +title: "Migrate from Jekyll" +date: 2014-03-10 +tags: ["go", "golang", "hugo", "jekyll", "static-site-generator"] +draft: true +--- + +## Move static content to `static` +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 + + ▾ / + ▾ images/ + logo.png + +should become + + ▾ / + ▾ static/ + ▾ images/ + logo.png + +Additionally, you'll want any files that should reside at the root (such as `CNAME`) to be moved to `static`. + +## 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](/overview/configuration/) for details. + +## Set your configuration publish folder to `_site` +The default is for Jekyll to publish to `_site` and for Hugo to publish to `public`. If, like me, you have [`_site` mapped to a git submodule on the `gh-pages` branch](http://blog.blindgaenger.net/generate_github_pages_in_a_submodule.html), you'll want to do one of two alternatives: + +1. Change your submodule to point to map `gh-pages` to public instead of `_site` (recommended). + + git submodule deinit _site + git rm _site + git submodule add -b gh-pages git@github.com:your-username/your-repo.git public + +2. 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](http://jekyllrb.com/docs/templates/) if you need to refresh your memory on how you built your blog and [Hugo's template](/layout/templates/) to learn Hugo's way. + +As a single reference data point, converting my templates for [heyitsalex.net](http://heyitsalex.net/) took me no more than a few hours. + +## Convert Jekyll plugins to Hugo shortcodes +Jekyll has [plugins](http://jekyllrb.com/docs/plugins/); Hugo has [shortcodes](/doc/shortcodes/). It's fairly trivial to do a port. + +### Implementation +As an example, I was using a custom [`image_tag`](https://github.com/alexandre-normand/alexandre-normand/blob/74bb12036a71334fdb7dba84e073382fc06908ec/_plugins/image_tag.rb) 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. + +Jekyll's plugin: + + module Jekyll + class ImageTag < 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+)"(.*?)"(\s+)->((https?:\/\/|\/)(\S+))(\s*)/i + IMAGE_URL_WITH_CAPTION = /((https?:\/\/|\/)(\S+))(\s+)"(.*?)"/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 = "
" + else + source = "
" + end + if @link + source += "" + end + source += "" + if @link + source += "" + end + source += "
#{@caption}
" if @caption + source += "
" + source + end + end + end + Liquid::Template.register_tag('image', Jekyll::ImageTag) + +is written as this Hugo shortcode: + + +
+ {{ with .Get "link"}}{{ end }} + + {{ if .Get "link"}}{{ end }} + {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} +
{{ if isset .Params "title" }} + {{ .Get "title" }}{{ end }} + {{ if or (.Get "caption") (.Get "attr")}}

+ {{ .Get "caption" }} + {{ with .Get "attrlink"}} {{ end }} + {{ .Get "attr" }} + {{ if .Get "attrlink"}} {{ end }} +

{{ end }} +
+ {{ end }} +
+ + +### 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](http://heyitsalex.net/) 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](https://github.com/alexandre-normand/alexandre-normand/compare/869d69435bd2665c3fbf5b5c78d4c22759d7613a...b7f6605b1265e83b4b81495423294208cc74d610). diff --git a/content/post/second-post.md b/content/post/second-post.md new file mode 100644 index 0000000..ce17325 --- /dev/null +++ b/content/post/second-post.md @@ -0,0 +1,10 @@ +--- +title: "Second Post" +date: 2018-03-10 +tags: [] +draft: true +--- + +# What makes this special? + +I have no idea. diff --git a/content/post/what-this-is.md b/content/post/what-this-is.md new file mode 100644 index 0000000..935c19f --- /dev/null +++ b/content/post/what-this-is.md @@ -0,0 +1,12 @@ +--- +title: "I Dont Know What This Is" +date: 2018-04-12 +tags: [] +draft: true +--- + + +# Do know + +Yes I do. + diff --git a/content/project/nas-101.md b/content/project/nas-101.md new file mode 100644 index 0000000..46478e1 --- /dev/null +++ b/content/project/nas-101.md @@ -0,0 +1,13 @@ +--- +title: "Nas 101" +description: "" +repo: "" +tags: [] +weight: 0 +draft: true +--- + + +# NAS 101 + +Yeah right?