GoPablo a static site generator.
- Introduction
- 1. Installing Node
- 2. Set Up Project
- 3. CSS, PostCSS and Sass
- 4. Images and Fonts
- 5. JavaScript ES6
- 6. External Libraries
- 7. Code Style Rules
- 8. Deploy
- 9. Audit and Page Speed
TL;DR
Install dependencies
npm install
Runs the app in the development mode
Build and open your browser to http://localhost:3000.
npm run dev
Linting JS & CSS
npm run lint
Builds distribution files for the app in production
npm run prod
Ready to deploy
Introduction
GoPablo is a static site generator with a modern development workflow, integrated web server, auto-reload, CSS preprocessors, and ES6 ready.
Features
Includes | |
---|---|
Live Server | |
Hot Reload & CSS Injection | |
⚙ | Babel 7 |
Express Server | |
Code Minification | |
Image Compression | |
Templating & Partial HTML Injection | |
PostCSS & Next Generation CSS | |
Cache-Busting | |
Distribution Files |
GoPablo requires Node v7.5 . This is the only global dependency. You can download Node here.
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
File Structure
├── build/ # Build files
├── dist/ # Distribution files
├── src/ # Source files
│ ├── assets/ # Assets directory
│ ├── css/ # CSS files
│ ├── fonts/ # Fonts directory
│ ├── img/ # Image directory
│ ├── js/ # JavaScript files
│ ├── etc/ # Extra files
│ ├── includes/ # HTML template partials
│ ├── index.html # Index page
└── .babelrc # Babel configuration
└── .gitignore # Git ignored files
└── .stylelintrc # Stylelint configuration file
└── gulpfile.js # Gulp configuration
└── LICENSE # License agreements
└── package-lock.json # Packages lock file
└── package.json # Node packages
└── README.md # You are reading this
└── server.js # Express server
To install GoPablo you need to clone the repository from GitHub:
git clone https://github.com/luangjokaj/gopablo
- This will clone the repository on your local machine. Navigate to the newly created folder and install the dependencies:
INSTALL DEPENDENCIES
npm install
START WORKFLOW
- We are ready to start our development server with the command:
npm run dev
Templating and HTML Partials
To avoid repetitive HTML code, GoPablo uses gulp-file-include. It has a simple templating synthax and allows to re-use chunks of code written in separate files. These partials are located in the directory:
src/includes/
For more information check out their documentation and examples: https://github.com/haoxins/gulp-file-include
New pages
To create new pages, simply create new .html files in the src/
directory.
Generate production files
To generate your distribution files run the command:
npm run prod
The files will be generated in the dist/
directory.
PostCSS
By default GoPablo supports PostCSS, a similar preprocessor to Sass, Less and others but with more functionality. On top of that PostCSS is 3x faster than Sass and 4x faster than Less. Features come in the shape of PostCSS plugins. Think of these like using Lego, where each piece is a different feature that can transform your CSS in some way. PostCSS lets you stick these pieces together so that you can build up your own feature set, adding and removing plugins as and when you need them. postcss-preset-env is installed by default. Read more about PostCSS here.
POSTCSS PLUGINS
GoPablo has two different sets of PostCSS plugins – one for the development environment (pluginsListDev) and one for the production task (pluginsListProd).
//-------------------------------------------------------------------------------------------------- /* ------------------------------------------------------------------------------------------------- PostCSS Plugins ------------------------------------------------------------------------------------------------- */ const pluginsDev = [ postcssImport, postCSSMixins, postcssPresetEnv({ stage: 0, features: { 'nesting-rules': true, 'color-mod-function': true, 'custom-media': true, }, }), ]; const pluginsProd = [ postcssImport, postCSSMixins, postcssPresetEnv({ stage: 0, features: { 'nesting-rules': true, 'color-mod-function': true, 'custom-media': true, }, }), require('cssnano')({ preset: [ 'default', { discardComments: true, }, ], }), ]; //--------------------------------------------------------------------------------------------------
WRITING CSS
The starting point for CSS is the file:
src/assets/css/styles.css
Sass
GoPablo is super flexible. You can install Sass and use it as the main CSS preprocessor:
npm install gulp-sass --save-dev
Include Sass in gulpfile.js:
const sass = require('gulp-sass');
Change the gulp tasks stylesDev to:
function stylesDev() { return src('./src/assets/css/styles.scss') .pipe(sourcemaps.init()) .pipe(sass().on("error", sass.logError)) .pipe(sourcemaps.write('.')) .pipe(dest('./build/assets/css')) .pipe(browserSync.stream({ match: '**/*.css' })); }
Also the watch task has to be changed in order to watch for .scss filetypes:
watch('./src/assets/css/**/*.scss', stylesDev);
Change the gulp tasks styleProd to:
function stylesProd() { return src('./src/assets/css/styles.scss') .pipe(sass().on("error", sass.logError)) .pipe(dest('./dist/assets/css')) }
Images
It is recommended to store image assets in the directory:
src/assets/img/
In the production build SVGs and other image assets will go through a minification process.
Fonts
Fonts are always special. Your fonts should be stored in:
src/assets/fonts/
Then you can include them in your CSS:
@font-face { font-family: 'Helvetica Neue Thin'; src: url('./fonts/Helvetica-Neue-Thin.eot'); src: url('./fonts/Helvetica-Neue-Thin.eot') format('eot'), url('./fonts/Helvetica-Neue-Thin.woff2') format('woff2'), url('./fonts/Helvetica-Neue-Thin.woff') format('woff'), url('./fonts/Helvetica-Neue-Thin.ttf') format('truetype'), url('./fonts/Helvetica-Neue-Thin.svg') format('svg'); }
GoPablo supports ES6 JavaScript with Babel. Babel has support for the latest version of JavaScript through syntax transformers. These plugins allow you to use new syntax, right now without waiting for browser support.
Write ES6 JavaScript
Your JavaScript code should be located in:
src/assets/js/
GoPablo will watch for changes under the js directory and bundle the code in a single file, which will be included in the footer of the page as:
footer-bundle.js
Check the gulp configuration to learn more about how JavaScript is generated.
Including external JavaScript libraries is as simple as installing the npm script and including it in the gulpfile.js
/* ------------------------------------------------------------------------------------------------- Header & Footer JavaScript Boundles -------------------------------------------------------------------------------------------------- */ const headerJS = [ './node_modules/jquery/dist/jquery.js', './node_modules/nprogress/nprogress.js', './node_modules/aos/dist/aos.js', './node_modules/isotope-layout/dist/isotope.pkgd.js' ]; const footerJS = [ './src/assets/js/**' ]; //--------------------------------------------------------------------------------------------------
You can include the scripts in the head of the page before the DOM is loaded by placing them in the headerJS array or in the footer of the page after the DOM is loaded in the footerJS array. Only footer scripts are processed with Babel thus supporting ES6, however you can change this in the configuration if you want to run both header and footer scripts with Babel.
A build restart is required for changes to take effect.
GoPablo comes with its own set of code style rules:
.stylelintrc
Lint CSS
Before pushing changes make sure you have clean and consistent CSS. Run stylelint with the command:
npm run lint
There are a lot of possiblities and different ways to deploy your static website. The most traditional one being: generating your distribution files and uploading them manually, usually FTP.
Heroku
With the help of a simple Express server, with GoPablo we can deploy to heroku out of the box.
- Create Heroku application:
heroku create
. - Push the branch to Heroku origins:
git push heroku master
Automated Netlify deployments
Netlify is a great service that can be used to deploy generated websites. All you have to do is:
- Connect your GitHub repository.
- Choose Branch to deploy, usually:
master
. - Set the Build command to:
npm run prod
. - Set the Publish directory to:
dist/
.
We are live
v0.0.1
- Meet GoPablo.
MIT
96 comments
Hi, its pleasant paragraph on the topic of media print, we all know media
is a great source of data.
Hello! Do you use Twitter? I’d like to follow you if that would be okay.
I’m undoubtedly enjoying your blog and look forward to new posts.
If you are going for most excellent contents like myself, simply pay a quick visit this site all the time
because it offers quality contents, thanks
Hi would you mind stating which blog platform you’re working
with? I’m going to start my own blog soon but I’m having a hard time deciding
between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your layout seems different then most
blogs and I’m looking for something completely unique.
P.S Apologies for being off-topic but I had to ask!
I want to to thank you for this excellent read!! I certainly enjoyed every little bit of it.
I have got you book marked to look at new stuff you post…
Hi there! Someone in my Myspace group shared
this site with us so I came to check it out. I’m definitely loving
the information. I’m bookmarking and will be tweeting this to my followers!
Wonderful blog and excellent style and design.
What’s up friends, its great post on the topic of educationand entirely
defined, keep it up all the time.
Fine way of explaining, and good post to take facts
regarding my presentation subject, which i am going to present in college.
wonderful publish, very informative. I’m wondering why the
opposite specialists of this sector don’t notice this.
You must continue your writing. I’m sure, you’ve a great
readers’ base already!
Very energetic post, I liked that bit. Will there be a part
2?
Aw, this was an exceptionally good post. Taking the
time and actual effort to make a superb article… but what can I say… I put things off a lot and never manage to get anything done.
Hi there, I found your blog by means of Google whilst searching for a related matter, your web site got
here up, it seems to be good. I’ve bookmarked it in my google bookmarks.
Hello there, simply was alert to your weblog through Google, and located
that it is really informative. I am gonna watch out for brussels.
I’ll be grateful in the event you continue this {in future}.
Numerous people might be benefited out of your writing. Cheers!
of course like your web site but you need to take
a look at the spelling on quite a few of your posts.
Many of them are rife with spelling issues and I to find it very
troublesome to tell the truth nevertheless I’ll surely come back
again.
Thanks in favor of sharing such a fastidious
thinking, article is pleasant, thats why i have read it entirely
My brother recommended I might like this website. He was once totally right.
This post truly made my day. You cann’t imagine just
how so much time I had spent for this info! Thank you!
I will right away seize your rss feed as I can not to find your email subscription hyperlink or newsletter service.
Do you’ve any? Please permit me know so that I may subscribe.
Thanks.
It is perfect time to make a few plans for the future and it’s time to
be happy. I’ve learn this post and if I may I wish
to recommend you few attention-grabbing issues or suggestions.
Maybe you could write subsequent articles relating to this article.
I want to learn more things approximately it!
This page truly has all of the information I wanted about this subject and didn’t know who to
ask.
I’m not that much of a online reader to be honest but your blogs really nice, keep it up!
I’ll go ahead and bookmark your website to come back later on. All
the best
I simply could not leave your site before suggesting that I actually enjoyed the standard information an individual supply in your visitors?
Is gonna be again incessantly to check up on new posts
Interesting blog! Is your theme custom made or
did you download it from somewhere? A theme like yours with a few simple tweeks
would really make my blog stand out. Please let me know where you got your design. Thanks a lot
Greate article. Keep writing such kind of info on your
site. Im really impressed by your site.
Hello there, You have done an excellent job. I will definitely digg it and individually recommend to my friends.
I am sure they will be benefited from this web site.
Peculiar article, just what I needed.
Aw, this was a really good post. Taking the time and actual effort to create
a superb article… but what can I say… I hesitate a
lot and never manage to get anything done.
Aw, this was an extremely good post. Finding the
time and actual effort to make a really good article…
but what can I say… I hesitate a whole lot and never manage
to get anything done.
Simply want to say your article is as astonishing. The clearness for
your post is simply nice and i could suppose you are knowledgeable on this subject.
Well together with your permission let me to seize your
feed to keep up to date with forthcoming post. Thanks one million and please carry on the enjoyable work.
Do you mind if I quote a few of your articles as long as
I provide credit and sources back to your weblog?
My blog site is in the very same area of interest as yours and my visitors
would certainly benefit from a lot of the information you provide here.
Please let me know if this ok with you. Many thanks!
This is my first time pay a quick visit at here and i am genuinely pleassant to read
all at alone place.
It’s an amazing article designed for all the online viewers;
they will get advantage from it I am sure.
It’s awesome for me to have a web page, which is valuable in support of my knowledge.
thanks admin
Hello there, just became aware of your blog through Google, and found that it
is truly informative. I am going to watch out for brussels.
I will be grateful if you continue this {in future}.
Numerous people will be benefited from your writing.
Cheers!
Wonderful article! We will be linking to this great article on our site.
Keep up the great writing.
Hey there! This post couldn’t be written any better!
Reading this post reminds me of my old room mate!
He always kept chatting about this. I will forward this post to him.
Fairly certain he will have a good read. Thanks for sharing!
Pretty! This was a really wonderful post. Thanks for supplying this info.
I am genuinely glad to glance at this webpage posts which consists of plenty of valuable data, thanks
for providing these information.
Hey! This post couldn’t be written any better! Reading this post reminds me of my good old room mate!
He always kept chatting about this. I will forward this write-up to him.
Fairly certain he will have a good read. Thanks for sharing!
Superb blog! Do you have any tips and hints for aspiring writers?
I’m planning to start my own blog soon but I’m a little lost
on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are
so many choices out there that I’m totally overwhelmed .. Any suggestions?
Cheers!
There’s certainly a lot to learn about this topic. I like all of the points you
made.
Quality articles or reviews is the important to be a focus for the people to pay a quick
visit the site, that’s what this web page is providing.
Hey there! I know this is kinda off topic nevertheless I’d
figured I’d ask. Would you be interested in trading links or maybe guest writing a blog post or
vice-versa? My website addresses a lot of the same subjects as yours
and I think we could greatly benefit from each other.
If you happen to be interested feel free to shoot me an email.
I look forward to hearing from you! Terrific blog by
the way!
Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot
you an e-mail. I’ve got some suggestions for your
blog you might be interested in hearing. Either way, great blog
and I look forward to seeing it grow over time.
We are a bunch of volunteers and starting a
brand new scheme in our community. Your site provided us with helpful information to work on. You’ve done
an impressive activity and our entire neighborhood will be thankful to you.
I am in fact grateful to the holder of this website who has shared this impressive
post at at this place.
That is a great tip especially to those new to the blogosphere.
Brief but very precise info… Thank you for sharing this one.
A must read article!
Link exchange is nothing else but it is only placing the other person’s blog link on your
page at proper place and other person will also do same for you.
It’s an remarkable article designed for all the internet
viewers; they will take advantage from it I am sure.
Ahaa, its good dialogue about this post here at this
webpage, I have read all that, so at this time me also
commenting here.
Hello, i think that i saw you visited my site so i came to “return the favor”.I am attempting to find things to improve my site!I suppose its ok to use a few of your ideas!!
I don’t even know how I ended up here, but I thought this post was good.
I don’t know who you are but certainly you are going
to a famous blogger if you aren’t already 😉 Cheers!
Have you ever considered about including a little bit more than just your articles?
I mean, what you say is important and all. However think of if you added some great photos or video clips to give your posts more,
“pop”! Your content is excellent but with images and clips, this blog could certainly be one
of the best in its field. Good blog!
It’s fantastic that you are getting ideas from this post as well
as from our discussion made at this time.
Do you have any video of that? I’d want to find out some additional
information.
Hi to every one, as I am really eager of reading this webpage’s post to be updated daily.
It carries nice material.
Wow, wonderful weblog layout! How long have you ever been running a blog for?
you made blogging look easy. The whole glance of your web site is excellent,
let alone the content material!
This text is invaluable. When can I find out more?
I do not know if it’s just me or if perhaps everyone else encountering issues with your site.
It appears like some of the text in your content
are running off the screen. Can someone else please comment and let me know if this is happening to them as well?
This might be a problem with my web browser because I’ve had this happen previously.
Kudos
Hi there to all, the contents present at this site are in fact amazing for people experience,
well, keep up the good work fellows.
This is my first time visit at here and i am genuinely impressed to read
all at alone place.
I’m excited to uncover this site. I want to to thank you for
ones time due to this wonderful read!! I definitely enjoyed every bit of it
and I have you saved to fav to see new things on your
blog.
If you wish for to improve your knowledge only keep visiting this website and be
updated with the hottest news update posted here.
Hi! This is kind of off topic but I need
some guidance from an established blog. Is it
hard to set up your own blog? I’m not very techincal but I can figure
things out pretty quick. I’m thinking about setting up
my own but I’m not sure where to start. Do you have any points or suggestions?
Many thanks
I visited many blogs but the audio feature for audio songs current at
this web page is in fact superb.
Everything is very open with a precise description of the issues.
It was really informative. Your website is extremely helpful.
Many thanks for sharing!
Hello There. I found your blog using msn. That is a really neatly written article.
I’ll be sure to bookmark it and come back to learn more
of your helpful info. Thank you for the post. I’ll certainly comeback.
I’ve been exploring for a little bit for any high-quality
articles or blog posts on this kind of space . Exploring in Yahoo I finally stumbled upon this site.
Reading this info So i’m happy to convey that I’ve a
very just right uncanny feeling I came upon exactly what I needed.
I so much for sure will make sure to do not disregard this website and provides
it a look regularly.
Thanks for ones marvelous posting! I truly enjoyed reading it, you
are a great author. I will be sure to bookmark your blog and definitely will come back down the road.
I want to encourage you to ultimately continue your great job, have a
nice evening!
Wow! In the end I got a webpage from where I know how to in fact take useful facts regarding my study and knowledge.
I enjoy what you guys tend to be up too. This type of clever work and exposure!
Keep up the wonderful works guys I’ve added you guys to our blogroll.
Have you ever considered about adding a little bit more than just your articles?
I mean, what you say is valuable and all.
Nevertheless think about if you added some great visuals
or video clips to give your posts more, “pop”! Your
content is excellent but with pics and videos, this site
could undeniably be one of the greatest in its niche.
Terrific blog!
Good information. Lucky me I ran across your blog by chance (stumbleupon).
I’ve book marked it for later!
Thanks for ones marvelous posting! I seriously enjoyed reading it, you will
be a great author.I will be sure to bookmark your blog and definitely will come back at some point.
I want to encourage yourself to continue your great job, have a nice
morning!
Hi there! This is my 1st comment here so I just
wanted to give a quick shout out and say I truly enjoy reading your blog posts.
Can you recommend any other blogs/websites/forums that go over the same
topics? Thanks a ton!
That is a good tip particularly to those fresh to the blogosphere.
Short but very accurate information… Many thanks for sharing this one.
A must read post!
Hi! This post could not be written any better!
Reading through this post reminds me of my previous
room mate! He always kept talking about this. I will forward this page to him.
Fairly certain he will have a good read. Thank you for sharing!
For latest information you have to pay a
quick visit internet and on the web I found this web site
as a most excellent web site for most up-to-date updates.
What a material of un-ambiguity and preserveness of precious knowledge on the
topic of unexpected emotions.
An outstanding share! I’ve just forwarded this onto a coworker who was doing a
little research on this. And he actually bought me dinner because I discovered it for him…
lol. So allow me to reword this…. Thanks for the meal!!
But yeah, thanx for spending time to talk about this matter here on your internet
site.
As the admin of this site is working, no uncertainty very rapidly it will be renowned, due to its feature
contents.
whoah this blog is wonderful i like studying your
posts. Keep up the great work! You realize, a lot of people are looking
round for this info, you could aid them greatly.
I like the helpful info you supply to your articles.
I will bookmark your weblog and check once more here frequently.
I am fairly sure I’ll be informed lots of new stuff proper here!
Best of luck for the next!
Touche. Solid arguments. Keep up the great spirit.
This site was… how do you say it? Relevant!!
Finally I’ve found something which helped me. Appreciate it!
It’s great that you are getting thoughts from this post as well as from our discussion made
here.
This website was… how do you say it? Relevant!! Finally
I have found something that helped me. Thanks a lot!
I am actually grateful to the holder of this website who has shared this great post at at this place.
I am actually thankful to the owner of this website who has shared this enormous post at at this place.
Hello, Neat post. There’s an issue with your web site in web explorer, would check this?
IE still is the market chief and a big portion of people will miss your magnificent writing because of this problem.
Howdy! This blog post couldn’t be written much better! Looking through this article reminds me of my previous roommate!
He continually kept preaching about this. I will send this article to
him. Fairly certain he’s going to have a great read.
Many thanks for sharing!
Hello i am kavin, its my first time to commenting anywhere, when i read this paragraph i thought i could also
make comment due to this sensible article.
I was extremely pleased to uncover this great site.
I want to to thank you for your time due to this wonderful
read!! I definitely liked every part of it and
i also have you saved to fav to check out new things in your site.
My brother suggested I might like this web site.
He was entirely right. This post truly made my day.
You cann’t imagine just how much time I had spent for this information! Thanks!
I do believe all of the concepts you have presented for your post.
They’re very convincing and can certainly work. Still, the posts are
very short for newbies. May just you please prolong them a bit from next
time? Thank you for the post.
It’s very easy to find out any topic on web as compared to books, as I found this piece of writing at this website.
I was wondering if you ever thought of changing the layout of
your website? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so
people could connect with it better. Youve got an awful lot of text for only having 1 or
2 pictures. Maybe you could space it out better?
Hey there! I know this is kind of off topic but I was wondering if you knew
where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having
difficulty finding one? Thanks a lot!
Wow, incredible blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your
web site is fantastic, as well as the content!