-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
254 lines (172 loc) · 13.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!DOCTYPE html>
<html lang="en">
<head>
<title>Wade Foster</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="./theme/css/main.css" type="text/css" />
<link href="./feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Wade Foster ATOM Feed" />
<link href="./feeds/all.rss.xml" type="application/atom+xml" rel="alternate" title="Wade Foster RSS Feed" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="./css/ie.css"/>
<script src="./js/IE8.js" type="text/javascript"></script><![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="./css/ie6.css"/><![endif]-->
</head>
<body id="index" class="home">
<a href="https://github.com/wadefoster/wadefoster.github.com">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" />
</a>
<header id="banner" class="body">
<h1><a href=".">Wade Foster </a></h1>
<nav><ul>
<li><a href="./pages/about.html">About</a></li>
<li ><a href="./category/posts.html">posts</a></li>
</ul></nav>
</header><!-- /#banner -->
<aside id="featured" class="body">
<article>
<h1 class="entry-title"><a href="./creating-a-blog-in-python-hosted-on-github-using-pelican.html">Creating a blog in Python hosted on GitHub using Pelican</a></h1>
<footer class="post-info">
<abbr class="published" title="2011-03-17T00:00:00">
Thu 17 March 2011
</abbr>
<address class="vcard author">
By <a class="url fn" href="./author/Wade Foster.html">Wade Foster</a>
</address>
<p>In <a href="./category/posts.html">posts</a>. </p>
<p>tags: <a href="./tag/blog.html">blog</a><a href="./tag/python.html">python</a></p>
</footer><!-- /.post-info --><p>Tools don't make a good writer, but good tools can certainly help a writer get more done.</p>
<p>I've constantly struggled with the internal workings of Wordpress and always wanted a blog built on python. I've tried rolling my own blog in Django, but ultimately I don't want to maintain my own blog site.</p>
<p>I want something that is simple, light weight, and will get out of my way.</p>
<p>I think I've found a solution.</p>
<h2>Enter Pelican</h2>
<p>Pelican is a static page generator much like ruby's Jekyll. </p>
<p>It's written and maintained by <a href="https://twitter.com/#!/ametaireau">Alexis Métaireau</a>. </p>
<p>Why Pelican? Because I:</p>
<ul>
<li>can write blog posts in Sublime using markdown</li>
<li>don't need an internet connection to write</li>
<li>can publish posts using git</li>
<li>have free hosting via <a href="http://pages.github.com/">GitHub pages</a> that scales with me so if ever hit the front page of <a href="http://news.ycombinator.com/">HN</a> I'm good to go. </li>
</ul>
<h2>How to setup a blog with Pelican</h2>
<p>Setting up a blog with Python is pretty easy even for someone who hasn't written a ton of code.</p>
<p>First create a repo on GitHub with your repository. Mine is titled wadefoster.github.com.</p>
<p>Next you need to create a directory for storing your blog locally:</p>
<div class="codehilite"><pre><span class="nb">mkdir</span> <span class="n">mysite</span>
<span class="n">cd</span> <span class="n">mysite</span>
</pre></div>
<p>Once you have your directory set up you can optionally choose to create a <a href="http://www.doughellmann.com/docs/virtualenvwrapper/#">virtual environment</a> though this step isn't necessary.</p>
<div class="codehilite"><pre><span class="n">mkvritualenv</span> <span class="n">env_mysite</span>
<span class="n">workon</span> <span class="n">env_mysite</span>
</pre></div>
<p>Then run the following set of commands to make sure you initialize git and are able to push to GitHub. Substitute your repo name for mine where applicable. </p>
<div class="codehilite"><pre><span class="n">git</span> <span class="n">init</span>
<span class="n">touch</span> <span class="n">README</span>
<span class="n">git</span> <span class="n">add</span> <span class="n">README</span>
<span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">'first commit'</span>
<span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="n">origin</span> <span class="n">git</span><span class="nv">@github</span><span class="o">.</span><span class="n">com:WadeFoster</span><span class="o">/</span><span class="n">wadefoster</span><span class="o">.</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">.</span><span class="n">git</span>
<span class="n">git</span> <span class="nb">push</span> <span class="o">-</span><span class="n">u</span> <span class="n">origin</span> <span class="n">master</span>
</pre></div>
<p>Congrats. You've successful made your first commit. </p>
<p>From here we are ready to install pelican and markdown.</p>
<div class="codehilite"><pre><span class="n">pip</span> <span class="n">install</span> <span class="n">pelican</span>
<span class="n">pip</span> <span class="n">install</span> <span class="n">markdown</span>
</pre></div>
<p>The last thing you need to do is configure your settings file. </p>
<p>In the root of your directory create a settings.py file. Here's mine as an example:</p>
<div class="codehilite"><pre><span class="c1"># File Name: settings.py</span>
<span class="n">AUTHOR</span> <span class="o">=</span> <span class="s">'Wade Foster'</span>
<span class="n">CATEGORY_FEED_RSS</span> <span class="o">=</span> <span class="s">'feeds/%s.rss.xml'</span>
<span class="n">DEFAULT_CATEGORY</span> <span class="o">=</span> <span class="s">'blog'</span>
<span class="n">DISQUS_SITENAME</span> <span class="o">=</span> <span class="s">'wadefoster'</span>
<span class="n">FEED_RSS</span> <span class="o">=</span> <span class="s">'feeds/all.rss.xml'</span>
<span class="n">GITHUB_URL</span> <span class="o">=</span> <span class="s">'https://github.com/wadefoster/wadefoster.github.com'</span>
<span class="n">GOOGLE_ANALYTICS</span><span class="o">=</span><span class="s">'UA-30070965-1'</span>
<span class="n">SITEURL</span> <span class="o">=</span> <span class="s">'http://wadefoster.github.com'</span>
<span class="n">SITENAME</span> <span class="o">=</span> <span class="s">'Wade Foster'</span>
<span class="n">SOCIAL</span> <span class="o">=</span> <span class="p">((</span><span class="s">'twitter'</span><span class="p">,</span> <span class="s">'http://twitter.com/wadefoster'</span><span class="p">),</span>
<span class="p">(</span><span class="s">'github'</span><span class="p">,</span> <span class="s">'https://github.com/wadefoster'</span><span class="p">),)</span>
<span class="n">TAG_FEED</span> <span class="o">=</span> <span class="s">'feeds/%s.atom.xml'</span>
<span class="n">TIMEZONE</span> <span class="o">=</span> <span class="s">"America/Chicago"</span>
<span class="n">THEME</span><span class="o">=</span><span class="s">'notmyidea'</span>
<span class="n">TWITTER_USERNAME</span> <span class="o">=</span> <span class="s">'wadefoster'</span>
</pre></div>
<p>Now you are ready to start writing.</p>
<h2>Writing blog posts with Pelican using Markdown</h2>
<p>Pelican has us put all of our posts in a subdirectory within the root of our site.</p>
<div class="codehilite"><pre><span class="nb">mkdir</span> <span class="n">posts</span>
</pre></div>
<p>Personally, I call this directory 'posts.' In practice I've seen it called 'content,' 'source,' and a number of other things.</p>
<p>Inside the directory create and open a file called first.md. This is where we'll compose our first post using markdown.</p>
<p>Posts are then formatted using <a href="http://daringfireball.net/projects/markdown/syntax">markdown</a> and you can add a post title, the content of the post, and other meta data like so.</p>
<div class="codehilite"><pre><span class="c1"># File Name: first.md</span>
<span class="n">Date:</span> <span class="mi">2011</span><span class="o">-</span><span class="mi">3</span><span class="o">-</span><span class="mi">17</span>
<span class="n">Title:</span> <span class="n">My</span> <span class="n">First</span> <span class="n">Post</span>
<span class="n">Tags:</span> <span class="n">blog</span><span class="p">,</span> <span class="n">python</span>
<span class="n">Your</span> <span class="n">content</span> <span class="n">goes</span> <span class="n">here</span><span class="o">.</span>
</pre></div>
<p>Save your post and you are ready to publish. </p>
<h2>Publishing blog posts with Pelican</h2>
<p>First let's generate our blog.</p>
<div class="codehilite"><pre><span class="n">pelican</span> <span class="n">posts</span> <span class="o">-</span><span class="n">o</span> <span class="o">.</span> <span class="o">-</span><span class="n">s</span> <span class="n">settings</span><span class="o">.</span><span class="n">py</span>
</pre></div>
<p>We run the pelican command, point it to our posts directory, output the generated content to root and apply our settings file.</p>
<p>Next make sure things are running locally so lets fire up a server to view our blog. This should fire up our site on port 8000. </p>
<div class="codehilite"><pre><span class="n">python</span> <span class="o">-</span><span class="n">m</span> <span class="n">SimpleHTTPServer</span>
</pre></div>
<p>Look good? Then we're ready to check in our code and push to master on GitHub for publishing. </p>
<div class="codehilite"><pre><span class="n">git</span> <span class="n">add</span> <span class="o">.</span>
<span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">'added our first post'</span>
<span class="n">git</span> <span class="nb">push</span>
</pre></div>
<p>In about ten minutes GitHub will build your page at username.github.com. </p>
<h2>Using a Custom Domain</h2>
<p>If you want to use a custom domain, GitHub provides this functionality for free. </p>
<p>First add a file called CNAME in the root directory of your project with the domain as it's content like so.</p>
<div class="codehilite"><pre><span class="n">wadefoster</span><span class="o">.</span><span class="n">net</span>
</pre></div>
<p>Next add an A record to your DNS management for GitHub pointing to <code>207.97.227.245</code>.</p>
<p>It could take a while for the DNS changes to propagate, but you should be good to go. </p>
<p>If you'd like to further customize your pelican blog check out the <a href="http://pelican.notmyidea.org/en/2.8/index.html">pelican documentation</a>.</p><p>There are <a href="./creating-a-blog-in-python-hosted-on-github-using-pelican.html#disqus_thread">comments</a>.</p>
</article>
</aside><!-- /#featured -->
<section id="extras" class="body">
<div class="social">
<h2>social</h2>
<ul>
<li><a href="./feeds/all.atom.xml" rel="alternate">atom feed</a></li>
<li><a href="./feeds/all.rss.xml" rel="alternate">rss feed</a></li>
<li><a href="http://twitter.com/wadefoster">twitter</a></li>
<li><a href="https://github.com/wadefoster">github</a></li>
</ul>
</div><!-- /.social -->
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
<address id="about" class="vcard body">
Proudly powered by <a href="http://alexis.notmyidea.org/pelican/">pelican</a>, which takes great advantages of <a href="http://python.org">python</a>.
</address><!-- /#about -->
<p>The theme is by <a href="http://coding.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/">Smashing Magazine</a>, thanks!</p>
</footer><!-- /#contentinfo -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-30070965-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">
var disqus_shortname = 'wadefoster';
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
</body>
</html>