
Show HN: Publish blog post with a simple Git push - snehesht
https://github.com/snehesht/blog
======
jads
Always like seeing these types of projects.

One piece of feedback: that gif of the process needs to be recreated. It's far
too quick and the erroneous key strokes and typing/deleting is really
confusing. Recreate the gif, but make it slower and error free to clearly
demonstrate the process.

~~~
snehesht
thanks, It's rather long ( ~ 1:30 mins ) so I increased speed by 2.5x.

~~~
JoshTriplett
Most browsers support embedded videos now, which have the advantage that you
can rewind and pause. You could also provide a transcript or static
screenshots.

~~~
bentpins
The unfortunate thing is that GitHub flavoured markdown doesn't yet support
webm or other types of video embed.

~~~
icpmacdo
If you use github pages you can use the HTML5 video tag, here's an example
from my account's Github pages

[https://icpmacdo.github.io/](https://icpmacdo.github.io/)

[https://github.com/icpmacdo/icpmacdo.github.io](https://github.com/icpmacdo/icpmacdo.github.io)

~~~
snehesht
Github pages renders html so by default it supports video, However It's
totally different case with markdown files.

------
shade23
Dont want to be a bubble-burster here.This can also be achieved by picking any
of the blog engines[1] and hooking it up with a CI. Gives you much more
legroom then right?

[1]:[https://www.staticgen.com/](https://www.staticgen.com/)

~~~
wsc981
There's this guide on a "one cent blog"[0] that I've used to create my own
website / weblog with a custom domain. It uses Jekyll, CloudFlare and Travis-
CI. Probably a bit more work to set up then the tool created by the OP, but
also more flexible, I would think. The end result is much the same though. A
simple 'git push' is used to publish the blog.

\---

[0]: [https://hugotunius.se/2016/01/10/the-one-cent-
blog.html](https://hugotunius.se/2016/01/10/the-one-cent-blog.html)

~~~
K0nserv
I'm the author of "One Cent Blog" thanks for the mention glad it helped you.
One interesting difference between the approach described in my blog post(or
any other static method) is that you are not relying on a server or a database
that can fall over if you get a lot of traffic from say HN. Having static
files is a blessing because it scales wonderfully.

The approach in this post relies on maintaining infrastructure, keeping it up
to date and patched which for me is a lot of extra work I'd rather not do.
Using a standard VPS it's a lot more expensive too.

~~~
codazoda
I do this with jekyll and github but without s3 or travis-ci. I skimmed over
the blog but couldn't understand what value s3 adds vs letting github host it.
Cloudflare can do the https bits with github directly.

~~~
K0nserv
The main value is escaping the constraints on plugins and gems you are able to
use with Jekyll on GitHub pages. Don't remember of the top of my head but I
believe it's pretty limited.

------
p4bl0
Reminds me of my old project (still in use to this days by something like a
dozen people) fugitive [1].

[1] [http://shebang.ws/fugitive-readme.html](http://shebang.ws/fugitive-
readme.html)

------
jalami
I considered doing this with my hugo blog, but decided I wanted to do the work
on my client and keep my server stupid. In order to build my site, I have a
lot of minification, pdf generation, syntax highlighting etc, that requires a
few packages to be installed on the client.

If my server had to rebuild after a git push of a new post, I'd have to
install all of the tooling on the server. I just commit my post, then run _npm
deploy_ which rsyncs all the static assets to the server after building on the
client. This also makes it so I can see everything on my client easily before
deploying. If I was building a blog for someone else though, this would make
sense, stupid client, smart server, commit from anywhere.

~~~
snehesht
My motivation for this project was simple, I need a good interface to write my
articles from different devices and able to publish them without touching the
server.

I built this in such a way I don't need to think about database backups,
server side authentication, using dropbox to sync my unfinished articles.

This architecture offers me freedom to write on my phone (Termux) during
commute or sitting in the office and keep track of changes using git and
finally publishing the post by simply adding a record into metadata.json.

~~~
jalami
You could throw Jekyll, Middleman, Pelican or Hugo on the server and run their
build command with a git hook. Then you'd get the same result, but a
completely static website without the server needing flask to piece together
pages when a user hits the site.

The build times wouldn't be instantaneous as it would need to regenerate all
the pages, but Hugo is still really snappy for even a large site. You probably
post less than users access anyway.

This would still check all your boxes:

No database

No server side auth

Non-public drafts (metadata)

Commit from anywhere

Bonus: Dumb serving (only prebuilt static pages)

Optional bonus: Shortcodes, themes, bells whistles

The site would be built on the server so it wouldn't be completely dumb like
rsync-ing static pages to nginx or something, but that's the rub if you want
to be able to use clients with only git as a dependency.

Yours is a good solution, I'm just throwing an idea out there for a pre-baked
alternative. My original use case didn't call for mobile blogging (not a fan),
I run my own gitolite server so auth is already in my camp and I have a multi-
tooled build that I didn't want on the server. If something breaks, it happens
on my machine instead of on my server.

Also just a tip, maybe you want to put a <noscript> tag around an expanded
copy of your hamburger menu. Without javascript, your website navigation is
broken because you can't expand the menu.

Edit: by client, I mean blog-editing-computer not blog-reader's-computer.

~~~
snehesht
What you said is true but where's the fun in it. I started this project as a
simple django blog, included react little later and then scratched the whole
thing and finally built this. It was fun working on this.

About the menu, I was planning to update it to hamburger icon with animations.
For now the icon doesn't change and the menu is injected into adjacent/bottom
element based on screen size.

Thanks your feedback though.

------
libeclipse
How is this different to hosting a Jekyll site on github?

~~~
gkya
Jekyll on Github does not allow plugins. Though I'd say that this seems to be
a bit an overkill, one shouldn't need cntainers for this kinda task. Best
approach would be local build+rsync/ssh for a normal hosting. For github, I'd
build the site targeting another git repo that I'd push to github.

------
ams6110
I've been publishing stuff on the web for years using just a simple scp.

~~~
laurent123456
And if you need versioning, just create a git repository on the remote server.

    
    
        rsync -a ~/blog/ user@host:~/blog && \
        ssh user@host 'cd ~/blog && git add --all . && git commit -m "udpate"'

~~~
gkya
Shouldn't one not version-control the build-output?

------
Flaiming
Seems to me that publishing blog post through git push is much more work than
use some admin interface (for example Wordpress).

You can use it from any device (without aby app for CLI interface). You can
use for example VersionPress[1] for backups to git. And I don't get what's the
point of publishing without touching server, since you need to touch the
server to view published post.

[1] [https://versionpress.net/](https://versionpress.net/)

~~~
jalami
Different strokes.

I think maintaining the LAMP Wordpress stack, extensions, admin panel auth
security, whatever versionpress is etc. is more hassle than editing a text
file and pushing code. To devs, this editing is second nature.

Also, I'd take my desktop editor to a contentEditable any day.

------
fiatjaf
What about commit names? Here's what happens when you use git for commiting
changes that do not support a meaningful name:
[https://github.com/github/developer.github.com/commits/gh-
pa...](https://github.com/github/developer.github.com/commits/gh-pages)

------
johnnyo
How is this different from Jekyl?

~~~
snehesht
I haven't used jekyll much but I would say this stores posts in separate git
repo (github.com/snehesht/blogposts) and user doesn't need to update the
server every time he publishes a new post.

It uses github webhooks to alert server of any events related to the blogposts
repo. The server verifies the events using HMAC authnication ( see github docs
for more info) and then updates the local blogposts repo ( git pull)

~~~
flohofwoe
With github pages and Jekyll, updating the blog is also just a simple push of
the Jekyll sources. The HTML page generation will than happen on github's
side. Of course with this, you're locked down to 2 techs, github and Jekyll.

~~~
danso
Being locked into Jekyll is not such a huge deal, as the posts are all
Markdown with some YAML frontmatter, and other systems use the same post
conventions, such as Middleman. Github only provides the convenience of not
having to install Jekyll on your own system in order to publish. If you want
to throw it up to S3 or any other static file server, you just have to run
`jekyll build` yourself.

------
romanovcode
Yeah Gitlab provides this type of functionality out of the box. Whenever I
commit something to it I get updates on my website[0] immediately.

Same for my CV[1], whenever I change it in gitlab it picks it up, compiles the
latex to pdf and replaces the cv.pdf file.

[0]
[https://gitlab.com/stanislavromanov/stanislavromanov](https://gitlab.com/stanislavromanov/stanislavromanov)

[1]
[https://gitlab.com/stanislavromanov/cv](https://gitlab.com/stanislavromanov/cv)

~~~
michaelmior
So does GitHub

[https://help.github.com/articles/about-github-pages-and-
jeky...](https://help.github.com/articles/about-github-pages-and-jekyll/)

------
rcarmo
Both my current[1] and previous[2] blog engines work like this - as long as
the post tree is updated by git or Dropbox, they're perfectly happy. Plus I
can use whatever markup I want (even Jupyter notebooks).

1: [https://github.com/rcarmo/sushy](https://github.com/rcarmo/sushy) 2:
[https://github.com/rcarmo/yaki](https://github.com/rcarmo/yaki)

------
worg
Alternatively you can setup a pipeline on gitlab and let the runner
build/publish your blog

~~~
snehesht
That's an interesting idea, but I wanted this blog to be as simple as
possible.

------
minhajuddin
Shameless Plug: [https://zammu.in/](https://zammu.in/) is something which I
built. It is a CI for static site generators like Jekyll/Hugo/Middleman etc,.

~~~
michaelmior
Why would I want to use Zammu over just using Travis CI or any other existing
CI service? The only new feature I see is scheduled deploys. (It's not clear
to me from the description on the site how this work.) Unfortunately it
doesn't seem the SSG I currently use (Wintersmith) is supported anyway.
Although I don't see why adding specific support for each system should be
necessary.

------
jradd
Damn, this is cool. I have been meaning to build something similar, inspired
by Gollum, or Jekyl.

~~~
snehesht
Thanks a lot, feel free to use my code as you see fit.

~~~
jradd
I probably will :)

------
kayman
I use a similar workflow. Emacs Org mode --> HTML --> Git Push --> Auto
Publish

------
hendzen
It would be cool to implement this as githook -> AWS Lambda -> publish to s3
bucket.

~~~
snehesht
Lambda is cool to some extent, actually I'm working on a side project that
relies heavily on aws lambda.

------
nicky0
"simple" and Git don't go together.

~~~
jackweirdy
It's not user hostile, it's just only expert-friendly.

------
ramswaroop
Great project. Cheers!

I see that you use keybase.io, can you send me an invite if that's okay for
you?

~~~
abstractbeliefs
Are you still looking for an invite?

~~~
ramswaroop
I got one yesterday. Most probably a Hacker News reader gave me one :)

------
fiatjaf
`git push` is in no way simple.

~~~
flukus
Why not? are you saying the CLI isn't simple or git in particular?

