2022-10-10

I want to restore my old notes repository as my personal website.

Uh, I just want to install Jekyll, but now I have to deal with programming environments, etc.

I spent time googling what the latest version manager was and I was overwhelmed. I found this article which which was a little clearer than others about suggestions. I’ve used rvm and rbenv in the past. I decided to use asdf: https://asdf-vm.com/


# install asdf: https://asdf-vm.com/guide/getting-started.html
homebrew install asdf 

# Add asdf.sh to your ~/.zshrc
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc

# reload shell
source ~/.zshrc

# install plugin
asdf plugin add ruby

# install ruby
# use same version as Github pages: https://pages.github.com/versions/
asdf install ruby 2.7.4

# set local ruby
asdf local ruby 2.7.4

# reload shell again
source ~/.zshrc

# check version
asdf current

# install github pages deps (jekyll, etc)
gem install github-pages

# reload shell
source ~/.zshrc

# create jekyll project in pre-existing markdown dir
jekyll new . --force

# check current example
jekyll serve --incremental --watch

So now I have a very simple page, index.md. I changed it to HTML. Note that you YAML front-matter for Jekyll to process it, else it will stay vanilla HTML.

You don’t need to use _posts. They are just a built-in collection: https://jekyllrb.com/docs/collections/ Unfortunately, it seems folders do need preceding underscore. I will be creating my own collections.

It seems I can’t avoid moving all my notes into their own directory. What I definitely want to avoid is touching each file again to add front matter. I could either use a plugin, e.g. https://github.com/benbalter/jekyll-optional-front-matter, or I can just programmatically add the front matter to the top of each file. If I use the plugin I want to be able to restrict behavior to that specific collection.

I think it’s going to be easier to manipulate each file. I don’t want to deal with plugin that doesn’t quite do what I want. I still think it’s kinda weak though.

“For each file in _notes we want to prepend file with simplest front-matter possible.”

Oh no, here we go again… I swear I’ve done this multiple times in past, using a slightly different method each time. In rare cases I’ve used awk, but I usually use sed, after googling of course. I remember to use GNU sed, which is not what is installed on a mac. So brew install gnu-sed. I used this as a reference: https://unix.stackexchange.com/questions/99350/how-to-insert-text-before-the-first-line-of-a-file

Inside the notes folder:

# Prepend YAML front matter to each file
#
# ls lists items which we pipe to xargs
# execute sed for each item
# -i modifies file in-place instead of outputting to stdout
# '1i\ inserts the proceeding text at Line 1
ls | xargs -I {} gsed -i '1 i\---\n---\n' {}

Switching repos was easy:

Note by enabling custom domain the CNAME file is automatically added to repo.

The minimal requirements are now complete. I need to get a basic them working, particularly to fix code snippets. I then need to add some common HTML stuff to my default layout, which I don’t think I even have.

I’m happy to start adding things to this now.

Bonus: I found this during a google search – https://microsoft.github.io/code-with-engineering-playbook/. I want to read this later.