Octopress无法加载CSS [英] Octopress not loading css

查看:87
本文介绍了Octopress无法加载CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Nginx上配置Octopress时遇到问题

i'm having an issue configuring Octopress on Nginx

当我运行rake preview 一切正常运行,我可以访问http://xxx:4000并且博客看起来还不错

When i run rake preview everything runs correctly i can acces http://xxx:4000 and the blog looks just fine

当我运行rake deploy时,我仍然可以访问http://xxxx/octopress上的博客 但是看起来没有css/js

when i run rake deploy i can still access blog on http://xxxx/octopress but looks like no css/js

当我浏览代码并尝试到达screen.css时,指向css的链接为http://xxxx/stylesheets/screen.css,但必须为http://xxxx/octopress/stylesheets/screen.css

when i explore the code and try to reach screen.css the link to css is http://xxxx/stylesheets/screen.css but it must be http://xxxx/octopress/stylesheets/screen.css

这是Rakefile和_config.yml上的摘录

here are the extract on Rakefile and _config.yml

conf

# ----------------------- #
#      Main Configs       #
# ----------------------- #

url: http://xxxxx/octopress/
title: Lux Baptiste
subtitle: Moui Moui
author: Lux
simple_search: https://www.google.com/search
description:

耙子

## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ssh_user       = "root@XXXX"
ssh_port       = "22"
document_root  = "/var/www/octopress/"
rsync_delete   = false
rsync_args     = ""  # Any extra arguments to pass to rsync
deploy_default = "rsync"

我加入我的Nginx服务器块,如果可以帮助的话,请不要打

i join my nginx serverblock, dunno if it can help

server {
    ### This setting tells Nginx to use this configuration if it gets a request for
    ### yourblog.com
    server_name _;

    ### This is the location on the web server where your Octopress files are
    ### published. Setting this here means you don't have to set it for any of the
    ### individual locations you define below.
    root /var/www/octopress;

    ### This tells Nginx to use "index.html" as the default index page everywhere
    index index.html;

    ### This disables automatic directory index creation, since no one will be
    ### browsing your directories anyway
    autoindex off;

    ### Here we define the root location...
    location / {
    ### ...and then work some magic with "try_files", telling Nginx that for every
    ### request that comes in to /, it should first try to serve the URI exactly
    ### as it is, and if it doesn't find anything by that name to then try and
    ### serve the URI as a directory, and if it doesn't find a directory by that
    ### name to then spit out a 404 error and give up.
        try_files $uri $uri/ =404;
    }

    ### This location definition prevents Nginx from serving any files which begin
    ### with a dot, and further to not log any access attempts or 404s for files
    ### which begin with dots, to keep your access and error logs clean.
    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    ### This location definition prevents Nginx from serving any files which begin
    ### with a dollar sign, so Nginx will refuse to serve out a temp file if you
    ### are doing any editing inside a web-available directory
    location ~ ~$ {
        access_log off;
        log_not_found off;
        deny all;
    }
    ### These next two locations simply prevent Nginx from logging every time the
    ### favicon & robots.txt files are accessed, to keep the logs clean
    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
}

推荐答案

对其进行了修复,只需在_config.yml中更改这些行即可.

fixed it, just needed to change those lines in _config.yml

# ----------------------- #
#    Jekyll & Plugins     #
# ----------------------- #

# If publishing to a subdirectory as in http://xxx/project set 'root: /project'
root: /octopress/public

这篇关于Octopress无法加载CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆