Skip to content

Instantly share code, notes, and snippets.

@vaidik
Last active December 18, 2015 00:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaidik/5695027 to your computer and use it in GitHub Desktop.
Save vaidik/5695027 to your computer and use it in GitHub Desktop.

Hyde publisher plugin for publishing content to Github Pages (User Pages).

https://github.com/vaidik/vaidik.github.io/tree/dev/publishers

Usage

  • Make sure that the hyde project lives in your dev branch. master branch, in case of user github pages, is left for serving static files.
  • Create an orphan master branch.
cd <hyde project directory>
git checkout dev
mkdir publishers
cd publishers

# create three files

# this one will be empty
touch __init__.py

touch ghpages.py
# copy contents of ghpages.py to the file you just created

touch ghpages.sh
# copy contents of ghpages.sh to the file you just created

  • Add the following configuration to your site.yaml file:
publisher:
    ghpages:
        type: publishers.ghpages.GhPages
  • To publish your content:
# switch to dev branch


# edit your content


# commit your changes to branch dev


# generate the static files
hyde gen

# now publish
hyde publish -p ghpages
"""
Hyde publisher plugin for publishing to Github Pages.
"""
import os
import shutil
import subprocess
from hyde.publisher import Publisher
class GhPages(Publisher):
def initialize(self, settings):
pass
def publish(self):
super(GhPages, self).publish()
root = self.site.config.deploy_root_path
subprocess.call(['./publishers/ghpages.sh'])
#!/bin/bash
"
Hyde publisher plugin for publishing to Github Pages.
Script to do the actual static file shifting from dev to master.
"
# checkout master branch
git checkout master
if [ $? -eq 0 ]
then
cp -rf deploy/* .
# commited the changed static files
git add .
git commit -m "build - `date`"
# clean up
rm -rf deploy/
# publish to github pages
git push origin master
# go back to where you were
git checkout dev
else
echo "Error: you must commit changes made in your dev branch."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment