I am trying to push my blog onto gh-pages with gulp, but when it is in the repository there is no style. Here is the page, and here is my repository.
I have tried searching for the answer, but I don't really know what I can try further now. From what I understand, the page will be built through using the contents in _site, but I fail to see how.
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var cp = require('child_process');
var jade = require('gulp-jade');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
/**
* Build the Jekyll Site
*/
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit'})
.on('close', done);
});
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/**
* Wait for jekyll-build, then launch the Server
*/
gulp.task('browser-sync', ['sass', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
/**
* Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
*/
gulp.task('sass', function () {
return gulp.src('assets/css/main.scss')
.pipe(sass({
includePaths: ['css'],
onError: browserSync.notify
}))
.pipe(prefix(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('_site/assets/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css'));
});
/*
** Mikael used Gulp. It's super effective!
*/
gulp.task('jade', function(){
return gulp.src('_jadefiles/*.jade')
.pipe(jade())
.pipe(gulp.dest('_includes'));
});
/**
* Watch scss files for changes & recompile
* Watch html/md files, run jekyll & reload BrowserSync
*/
gulp.task('watch', function () {
gulp.watch('assets/css/**', ['sass']);
gulp.watch(['index.html', '_layouts/*.html', '_includes/*'], ['jekyll-rebuild']);
gulp.watch('_jadefiles/*jade', ['jade']);
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['browser-sync', 'watch']);
Your stylesheet is currently an absolute link in your HTML head
:
<link rel="stylesheet" href="/assets/css/main.css">
This makes it point to the following resource, which doesn't exist:
https://mothil93.github.io/assets/css/main.css
The real resource path you want is this:
https://mothil93.github.io/akirothesquid/assets/css/main.css
So you need to change all your internal links to be relative instead of absolute. For example for the above stylesheet, use this line instead:
<link rel="stylesheet" href="assets/css/main.css">
Once the substitution is made, the styles start to show up on your site.
Calling a recourse is made like this :
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/main.css">
or
<link rel="stylesheet" href="{{ "/assets/css/main.css" | prepend: site.baseurl }}">
So, in _config.yml
, you can set baseurl
to /akirothesquid
and use the jekyll way to point to ressources.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.