我试着用gulp把我的博客推到gh页面上,但是当它在存储库中时,就没有风格了。Here is the page,here is my repository.
我已经试过寻找答案,但我真的不知道我现在还能做什么。据我所知,该页面将通过使用网站中的内容来构建,但我看不到如何构建。

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']);

最佳答案

样式表当前是HTML中的绝对链接:

<link rel="stylesheet" href="/assets/css/main.css">

这使它指向以下不存在的资源:
https://mothil93.github.io/assets/css/main.css

您需要的真正资源路径是:
https://mothil93.github.io/akirothesquid/assets/css/main.css

所以你需要改变你所有的内部链接是相对的,而不是绝对的。例如,对于上述样式表,请改为使用此行:
<link rel="stylesheet" href="assets/css/main.css">

一旦替换完成,样式就开始出现在您的站点上。

关于git - 用gulpfile将内容推送到gh页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32443577/

10-13 05:51