Giblog - Web site and Blog builders you can manage with Git
Website
Website Example
Blog
Blog Example
Giblog is a utility to create your web site or blog. You can create your web site or blog using giblog command. All created files is static files, so you can manage them using git. You can freely customize your website by editting the build command.
giblog
build
# New empty web site $ giblog new mysite # New web site $ giblog new_website mysite # New blog $ giblog new_blog mysite # Change directory $ cd mysite # Add new entry $ giblog add # Build web site $ giblog build # Serve a web site $ giblog serve # Publish web site $ giblog publish origin main # Add new entry with home directory $ giblog add --home /home/kimoto/mysite # Build web site with home directory $ giblog build --home /home/kimoto/mysite
Giblog have the following features.
Build Website and Blog.
Git mangement. All created files is Static. you can manage files by git.
Linux, macOS, Windows Support. (In Windows, recommend installation of msys2)
Provide default CSS for Smart phone site.
Header, Hooter and Side bar support
You can customize Top and Bottom section of content.
You can customize HTML head.
Automatical Line break. p tag is automatically added.
Escape <, > automatically in pre tag
Title tag is automatically added from first h1-h6 tag.
Description meta tag is automatically added from first p tag.
You can customize your web site by Perl.
You can serve your web site in local environment. Contents changes is detected and build automatically(need Mojolicious).
Fast. Build 645 pages by 0.78 seconds in starndard linux environment.
Support Github Pages, both user and project page.
1. Create Empty website
"new" command create empty website. "mysite" is a name of your web site.
giblog new mysite
If you want to create empty site, choice this command. Templates and CSS is empty and provide minimal site building process.
2. Create Website
"new_website" command create simple website. "mysite" is a name of your web site.
giblog new_website mysite
If you want to create simple website, choice this command. Top page "templates/index.html" is created. List page "templates/list.html" is created, which is prepare to create blog entry pages easily for feature.
CSS is responsive design and supports smart phone and provide basic site building process.
3. Create Blog
"new_blog" command create empty website. "mysite" is a name of your web site.
giblog new_blog mysite
If you want to create blog, choice this prototype. Top page "templates/index.html" is created, which show 7 days entries. List page "templates/list.html" is created, which show all entries links.
CSS is responsive design and supports smart phone and provide basic blog building process.
You need to change directory to "mysite" before run "add" command if you are in other directory.
cd mysite
"add" command add entry page.
giblog add
Created file name is, for example,
templates/blog/20080108132865.html
This file name contains current date and time.
To write new entry, You open it, write h2 head and content.
<h2>How to use Giblog</h2> How to use Giblog. This is ...
Other parts wrapping content like Header and footer is automatically added in building process.
If you want to create content page, put file into "templates" directory.
templates/access.html templates/profile.html
Then open these file, write h2 head and content.
You can put file into sub directory.
templates/profile/more.html
Note that "templates/static" and "templates/common" is special directories. Don't push content page files into these directories.
# Special directories you don't put content page files into templates/static templates/common
If you want to add static files like css, images, JavaScript, You put these file into "templates/static" directory.
Files in "templates/static" directory is only copied to public files by build process.
templates/static/js/jquery.js templates/static/images/logo.png templates/static/css/more.css
You can customize header, footer, side bar, top of content, bottom of content.
------------------------ Header ------------------------ Top of content | -----------------| |Side Content |bar | -----------------| Bottom of content| ------------------------ Footer ------------------------
If you want to edit these section, you edit these files.
templates/common/header.html Header templates/common/top.html Top of content templates/common/side.html Side bar templates/common/bottom.html Bottom of content templates/common/footer.html Footer
You can customize HTML header.
<html> <head> <!-- HTML header --> </head> <body> </body> </html>
If you want to edit HTML header, you edit the following file.
templates/common/meta.html
You need to change directory to "mysite" before run "build" command if you are in other directory.
"build" command build web site.
giblog build
What is build process?
build process is writen in "lib/Giblog/Command/build.pm".
"build" command only execute "run" method in "Giblog::Command::build.pm" .
# "lib/Giblog/Command/build.pm" in web site created by "new_blog" command package Giblog::Command::build; use base 'Giblog::Command'; use strict; use warnings; use File::Basename 'basename'; sub run { my ($self, @args) = @_; # API my $api = $self->api; # Read config my $config = $api->read_config; # Copy static files to public $api->copy_static_files_to_public; # Get files in templates directory my $files = $api->get_templates_files; for my $file (@$files) { # Data my $data = {file => $file}; # Get content from file in templates directory $api->get_content($data); # Parse Giblog syntax $api->parse_giblog_syntax($data); # Parse title $api->parse_title_from_first_h_tag($data); # Edit title my $site_title = $config->{site_title}; if ($data->{file} eq 'index.html') { $data->{title} = $site_title; } else { $data->{title} = "$data->{title} - $site_title"; } # Add page link $api->add_page_link_to_first_h_tag($data, {root => 'index.html'}); # Parse description $api->parse_description_from_first_p_tag($data); # Read common templates $api->read_common_templates($data); # Add meta title $api->add_meta_title($data); # Add meta description $api->add_meta_description($data); # Build entry html $api->build_entry($data); # Build whole html $api->build_html($data); # Write to public file $api->write_to_public_file($data); } # Create index page $self->create_index; # Create list page $self->create_list; }
You can customize build process if you need.
If you need to know Giblog API, see Giblog::API.
You can serve web site by serve command.
serve
# Serve web site giblog serve
You see the following message.
Web application available at http://127.0.0.1:3000
This command is same as the following code. morbo command of Mojolicious start up serve.pl.
serve.pl
# Same as the following morbo -w giblog.conf -w lib -w templates serve.pl
If giblog.conf, files in templates or lib directory is changed, Web site is automatically rebuild.
giblog.conf
templates
lib
If you use before Giblog 2.0, you can serve a web site by the following way.
# Old style before Giblog 2.0 morbo serve.pl
You can publish the web site by publish command.
publish
# Publish the web site giblog publish origin main
This is the same as the following command. In this example, the repository name is origin and the branch name is main. YY-mm-dd HH:MM:SS is current date and time.
git -C public add --all git -C public commit -m "Published by Giblog at YY-mm-dd HH:MM:SS" git -C public push origin main
Giblog config file is "giblog.conf".
This is Perl script and return config as hash reference.
use strict; use warnings; use utf8; # giblog.conf { site_title => 'mysite😄', site_url => 'http://somesite.example', }
site_title => 'mysite😄'
Site title
site_url => 'http://somesite.example'
Site URL.
base_path => '/subdir'
Base path. Base path is used to deploy your site to sub directory.
For example, Project page URL of Github Pages is
https://yuki-kimoto.github.io/giblog-theme1-public/
You specify the following
base_path => '/giblog-theme1-public'
Top character of base_path must be slash "/".
HTML files is output into "public/giblog-theme1-public" directory.
These methods is internally methods. Normally, you don't need to know these methods. See Giblog::API to manipulate HTML contents.
my $api = Giblog->new(%params);
Create Giblog object.
Parameters:
home_dir - home directory
config - config
$giblog->run_command(@argv);
Run command system.
my $config = $giblog->config;
Get Giblog config.
my $home_dir = $giblog->home_dir;
Get home directory.
Giblog
Giblog::API
Giblog::Command
Giblog::Command::add
Giblog::Command::build
Giblog::Command::deploy
Giblog::Command::new
Giblog::Command::new_blog
Giblog::Command::new_website
Giblog::Command::publish
Giblog::Command::save
Giblog::Command::serve
Giblog doesn't support native Windows(Strawberry Perl, or Active Perl) because Giblog depends on Git and Mojolicious.
If you use Giblog in Windows, you can use msys2 or WSL2.
The lowest version of Perl is the same version as Mojolicious because Giblog depends on Mojolicious. The current version is Perl 5.16+.
Git 1.8.5+.
Giblog 3.0 is compatible with Giblog 2.0. You can upgrade from Giblog 2.0 to Giblog 3.0 naturally.
From Giblog 2.0 the lowest version of Perl depends on Mojolicious, so use the latest Perl as possible.
Git 1.8.5+ is required.
Giblog Official Site
Yuki Kimoto, <kimoto.yuki at gmail.com>
<kimoto.yuki at gmail.com>
Yasuaki Omokawa, <omokawa at senk-inc.co.jp>
<omokawa at senk-inc.co.jp>
Copyright 2018-2021 Yuki Kimoto.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install Giblog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Giblog
CPAN shell
perl -MCPAN -e shell install Giblog
For more information on module installation, please visit the detailed CPAN module installation guide.