Github Pages, Day 2

by Mike Levin

Saturday, May 21, 2022

We’re starting a lesson and will begin with a review of yesterday, but not everything from yesterday, because we covered so much. We will hit the essentials. Those essentials are:

  1. We are using Linux through Windows Terminal.
  2. From Windows Terminal, a.k.a. command-line or shell or CLI, which we know by the $ prompt, we can use such programs as:
    • vim
    • git
    • less
    • echo
    • ls
    • cd
    • pwd
  3. For web publishing, git is the one we’re using right now.
    • There is a publishing system built into Github called Github Pages.
    • Github Pages uses another system called Jekyll
    • Jekyll takes markdown files and turns them into pretty HTML files
    • Those HTML files are accessible from URLs such as:
    • https://natlevin.github.io/publishme/
  4. We learned quite a bit about git
    • We learned some of it’s history, that it was written by Linus Torvalds
    • We learned that a folder (a.k.a. directory) can get turned into a git repo (a.k.a. repository)
    • We learned that these git repos can also be kept on Github
    • We learned how to use git (a little bit)
  5. These are the git commands we learned:
    • Start by going to the Terminal
    • cd to where we want to make a new directory from
    • mkdir newlocation
    • cd newlocation
    • echo

So what is echo? Echo as a command, a.k.a. program that works like “print” from other systems such as kornshell and Python.

The trick with echo is that it’s normal use is this:

echo "Hello World"

But you can also use it like this:

echo "# Hello World" > index.md

…which actually creates the file by “redirecting” the output of echo into a file. This is similar to the “piping” trick we learned yesterday, but instead of the pipe | symbol to a program, it’s the greater-than > symbol to a file. Using » will make it create or append instead of create or replace.

Once the file exists, you can go into it with vim:

vim index.md

Once you’re in vim, you can practice markdown and macros.

Macros start by navigating to where you want it to begin.

This is often the beginning of a line for “easier control” reasons.

Hit the “q” key, and then one of the keys “a” through “z”. I usually choose “a” because of never having to think about it. I record a macro, it goes in a. But this is a choice. These are “registers”. They are the same registers you would use the double-quote (“) to copy into.

So macros go into registers. Normal copy/paste can go into the same registers. This may seem like a conflict, but it’s really cool for pasting recorded macros into your .vimrc.

If your .vimrc is already loaded, pasting a macro for permanent future use is as simple as pasting it into the .vimrc and “wrapping” it in:

let @x = '[paste recorded macro here]'

And from that point on whenever you run vim, you can play back that macro by typing:

@x

Once you’ve played back a macro, say to insert an html line-break, you don’t have to keep typing @x which is a little tedious. You can keep your finger on the shift-key and tap @@ which will replay the last macro.

In such a way, you can run the macro on each line in a list, so long as going back to the beginning of the line and down 1 line is at the end of the recorded macro.

I do this particular macro so much that I actually haven’t put it in my .vimrc so that I keep reminding myself how to record macros and that it’s a good idea.

foo bar
foo bar
foo bar
foo bar
foo bar

This has led me to such macros as turning…

some-keyworded-image.jpg

…into:

```markdown
![Some Keyworded Image](some-keyworded-image.jpg)
``` Okay, so we have done some practice markdown. Next step, publish!

Save and exit.

Turn folder into github repository by typing:

git init

Next, we add index.md to the new git repository by typing:

git add index.md

Next, we commit the changes by typing:

git commit -am "something"

The next step is on Github. We make a new repo using the + in the upper-right, give it a name that matches the folder on your machine.

It’s going to give the commands.

The 2nd to last line is wrong. It gives https where it should give git@github.com.

To fix this, click “SSH” before copying the last 3 lines to execute. You should see something like:

git remote add origin git@github.com:miklevin/experiment.git