Skip to content

Commit

Permalink
hacker blog template
Browse files Browse the repository at this point in the history
  • Loading branch information
pallavsen007 committed Oct 12, 2022
1 parent 24e0179 commit 9c3d092
Show file tree
Hide file tree
Showing 28 changed files with 1,335 additions and 1 deletion.
6 changes: 6 additions & 0 deletions 404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
layout: default
title: 404
---

This page does not exist. [Go back]({{ "/" | prepend: site.baseurl | replace: '//', '/' }}).
115 changes: 114 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,114 @@
# pallavsen
# The Hacker-Blog theme

*Hacker-Blog is a minimalistic, responsive jekyll theme built for hackers. It is based on the [hacker theme](https://github.com/pages-themes/hacker) for project pages.*

Demo: [https://ashishchaudhary.in/hacker-blog](https://ashishchaudhary.in/hacker-blog)

### Included

1. Pagination
2. SEO tags
3. Archive Page
4. About Page
5. RSS (`https://base-url/atom`)
6. Sitemap (`https://base-url/sitemap`)
7. Google Analytics (optional)

## Usage

1. Fork and Clone this repository
2. Customize your blog
3. Add a new post in `_posts/` directory with proper name format (as shown in placeholder posts)
4. Commit and push to master on a repository named `<githubusername.github.io>`.
5. Visit `<githubusername>.github.io`

## Local Build

If you want to see the changes before pushing the blog to Github, do a local build.

1. [`gem install jekyll`](https://jekyllrb.com/docs/installation/#install-with-rubygems)
2. `gem install jekyll-seo-tag`
3. `gem install jekyll-paginate`
4. `gem install jekyll-sitemap`
5. (`cd` to the blog directory, then:) `jekyll serve --watch --port 8000`
6. Go to `http://0.0.0.0:8000/` in your web browser.

*Note: In case you have set a `baseurl` different than `/` in `_config.yml`, go to `http://0.0.0.0:8000/BASEURL/` instead.*

### Local build using docker

```bash
docker run --rm -p 8000:8000 \
--volume="LOCATION_OF_YOUR_JEKYLL_BLOG:/srv/jekyll" \
-it tocttou/jekyll:3.5 \
jekyll serve --watch --port 8000
```

Replace `LOCATION_OF_YOUR_JEKYLL_BLOG` with the full path of your blog repository. Visit `http://localhost:8000/` to access the blog.

*Note: In case you have set a `baseurl` different than `/` in `_config.yml`, go to `http://0.0.0.0:8000/BASEURL/` instead.*

## Customizing

### Configuration variables

Edit the `_config.yml` file and set the following variables:

```yml
title: [The title of your blog]
description: [A short description of your blog's purpose]
author:
name: [Your name]
email: [Your email address]
url: [URL of your website]

baseurl: [The base url for this blog.]

paginate: [Number of posts in one paginated section (default: 3)]
owner: [Your name]
year: [Current Year]
```
*Note: All links in the site are prepended with `baseurl`. Default `baseurl` is `/`. Any other baseurl can be setup like `baseurl: /hacker-blog`, which makes the site available at `http://domain.name/hacker-blog`.*

Additionally, you may choose to set the following optional variables:

```yml
google_analytics: [Your Google Analytics tracking ID]
```

### About Page

Edit `about.md`

### Layout

If you would like to modify the site style:

**HTML**

Footer: Edit `_includes/footer.html`

Header: Edit `_includes/header.html`

Links in the header: Edit `_includes/links.html`

Meta tags, blog title display, and additional CSS: Edit `_includes/head.html`

Index page layout: Edit `_layouts/default.html`

Post layout: Edit `_layouts/post.html`

**CSS**

Site wide CSS: Edit `_sass/base.scss`

Custom CSS: Make `_sass/custom.scss` and use it. Then add `@import "custom";` to `css/main.scss`

**404 page**

Edit `404.md`

## License

CC0 1.0 Universal
32 changes: 32 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
title: Hacker-Blog
description: "A Jekyll Blog Theme For Hackers"
author:
name: "SomeHacker"
email: "[email protected]"
url: "https://ashishchaudhary.in/hacker-blog"

baseurl: /

source: .
destination: ./_site
permalink: /:title
paginate: 3
paginate_path: /page/:num/

defaults:
-
scope:
path: ""
type: "posts"
values:
layout: "post"

future: true
plugins:
- jekyll-seo-tag
- jekyll-paginate
- jekyll-sitemap

# Custom variables
owner : "SomeHacker"
year : "2020"
8 changes: 8 additions & 0 deletions _includes/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.google_analytics }}', 'auto');
ga('send', 'pageview');
</script>
9 changes: 9 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<footer>
<a href="https://creativecommons.org/licenses/by-nc/3.0/deed.en_US">
<span>
<b>{{ site.owner}}</b>
</span>
{% capture currentyear %}{{ 'now' | date: "%Y" }}{% endcapture %}
<span>© {{ currentyear }}</span>
</a>
</footer>
11 changes: 11 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
<meta name="generator" content="Jekyll">

<title>{%if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>

<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl | replace: '//', '/' }}">

<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="ATOM Feed" /> {% seo %}
</head>
11 changes: 11 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<header>
<div>
<a href="{{ "/" | prepend: site.baseurl | replace: '//', '/' }}">
{% assign owner_first_name = site.owner | split: " " %}
<h1>{{ owner_first_name[0] | downcase }}@home:~$</h1>
</a>
<div class="header-links">
{% include links.html %}
</div>
</div>
</header>
3 changes: 3 additions & 0 deletions _includes/links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a href="{{ "/archive" | prepend: site.baseurl | replace: '//', '/' }}"><h2 class="header-link">Archive</h2></a>
<a href="{{ "/about" | prepend: site.baseurl | replace: '//', '/' }}"><h2 class="header-link">About</h2></a>
<a href="{{ "/atom.xml" | prepend: site.baseurl | replace: '//', '/' }}"><h2 class="header-link">RSS</h2></a>
42 changes: 42 additions & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
{% include head.html %}

<body>
<div id="wrapper">
{% include header.html %}
<div class="container">
<section id="main_content">
{{ content }}
</section>
</div>
</div>

{% if paginator.total_pages > 1 %}
<div class="pagination">
{% if paginator.previous_page == 1 %}
<a href="{{ '/' | prepend: site.baseurl | replace: '//', '/' }}" class="page-item">&laquo;</a>
{% elsif paginator.previous_page%}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}" class="page-item">&laquo;</a>
{% else %}
<span class="page-item">&laquo;</span>
{% endif %} {% for page in (1..paginator.total_pages) %} {% if page == paginator.page %}
<span class="page-item">{{ page }}</span>
{% elsif page == 1 %}
<a href="{{ '/' | prepend: site.baseurl | replace: '//', '/' }}" class="page-item">{{ page }}</a>
{% else %}
<a href="{{ site.paginate_path | prepend: site.baseurl | replace: '//', '/' | replace: ':num', page }}" class="page-item">{{ page }}</a>
{% endif %} {% endfor %} {% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}" class="page-item">&raquo;</a>
{% else %}
<span class="page-item">&raquo;</span>
{% endif %}
</div>
{% endif %} {% include footer.html %}

{% if site.google_analytics %}
{% include analytics.html %}
{% endif %}
</body>

</html>
7 changes: 7 additions & 0 deletions _layouts/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
layout: default
---

<article>
{{ content }}
</article>
9 changes: 9 additions & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: default
---

<article>
<h2>{{ page.title }}</h2>
<time datetime="{{ page.date | date_to_xmlschema }}" class="by-line">{{ page.date | date_to_string }}</time>
{{ content }}
</article>
124 changes: 124 additions & 0 deletions _posts/2017-12-10-Another-Sample-Page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: Another Sample Page
published: true
---

Text can be **bold**, _italic_, ~~strikethrough~~ or `keyword`.

[Link to another page](another-page).

There should be whitespace between paragraphs.

There should be whitespace between paragraphs. We recommend including a README, or a file with information about your project.

# [](#header-1)Header 1

This is a normal paragraph following a header. GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

## [](#header-2)Header 2

> This is a blockquote following a header.
>
> When something is important enough, you do it even if the odds are not in your favor.
### [](#header-3)Header 3

```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l)
return true;
}
```

```ruby
# Ruby code with syntax highlighting
GitHubPages::Dependencies.gems.each do |gem, version|
s.add_dependency(gem, "= #{version}")
end
```

#### [](#header-4)Header 4

* This is an unordered list following a header.
* This is an unordered list following a header.
* This is an unordered list following a header.

##### [](#header-5)Header 5

1. This is an ordered list following a header.
2. This is an ordered list following a header.
3. This is an ordered list following a header.

###### [](#header-6)Header 6

| head1 | head two | three |
|:-------------|:------------------|:------|
| ok | good swedish fish | nice |
| out of stock | good and plenty | nice |
| ok | good `oreos` | hmm |
| ok | good `zoute` drop | yumm |

### There's a horizontal rule below this.

* * *

### Here is an unordered list:

* Item foo
* Item bar
* Item baz
* Item zip

### And an ordered list:

1. Item one
1. Item two
1. Item three
1. Item four

### And a nested list:

- level 1 item
- level 2 item
- level 2 item
- level 3 item
- level 3 item
- level 1 item
- level 2 item
- level 2 item
- level 2 item
- level 1 item
- level 2 item
- level 2 item
- level 1 item

### Small image

![](https://assets-cdn.github.com/images/icons/emoji/octocat.png)

### Large image

![](https://guides.github.com/activities/hello-world/branching.png)


### Definition lists can be used with HTML syntax.

<dl>
<dt>Name</dt>
<dd>Godzilla</dd>
<dt>Born</dt>
<dd>1952</dd>
<dt>Birthplace</dt>
<dd>Japan</dd>
<dt>Color</dt>
<dd>Green</dd>
</dl>

```
Long, single-line code blocks should not wrap. They should horizontally scroll if they are too long. This line should be long enough to demonstrate this.
```

```
The final element.
```
Loading

0 comments on commit 9c3d092

Please sign in to comment.