Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地测试正常,部署到线上就失效 #7

Closed
palemoky opened this issue Dec 10, 2016 · 15 comments
Closed

本地测试正常,部署到线上就失效 #7

palemoky opened this issue Dec 10, 2016 · 15 comments
Assignees

Comments

@palemoky
Copy link

palemoky commented Dec 10, 2016

我看了一下tag的配置文件,路径指向的是src="/js/tagcloud.js"src="/js/tagcanvas.js",也就是说,这两个文件都是生成再js目录下的,但我本地成功在这个目录是没有找到这两个文件的,之后用find命令找到在/public/js/下,在hexo的.gitignore文件中,这个目录是被忽略的,线上就是在js目录下找不到对应的两个文件而加载失败的。
随后我又将tag的配置文件路径指向`src="/public/js/tagcloud.js",部署到线上仍然不行,请问如何解决?这个标签云真的很不错的说。

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 10, 2016

可以的话,最好是 hexo clean && hexo g && hexo s 看看效果,然后再用 hexo d 部署。hexo clean 是必须的。

如果上述方案不行的话,采用下面的:
路径应该都是『/js/』目录。这个不需要改变的。
如果你是部署到 github 的话,你的博客是在 .deploy_git 目录下(和 public 同级)。
你看看这个目录里面有没有这两个 js 文件。
如果没有,临时的解决方案是把这两个 js 拷贝到 .deploy_git/js 目录,然后手动 git push

需要的更多信息:你的博客主题,hexo 版本。

@palemoky
Copy link
Author

palemoky commented Dec 10, 2016

首先非常感谢作者的回答!
按照作者的办法,我先是临时将两个js文件拷到.deploy_git/js,然后hexo cleanhexo d -g,发现并没有生效,在控制台仍然没有看到这两个文件,回头一看,放入.deploy_git/js中的文件都没了,然后又手动push了一次就好了。
再次感谢作者的解答!
我的博客主题是hexo-theme-primer
hexo版本是3.2.2

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 10, 2016

你试试删除 .deploy_git 文件夹,然后 hexo clean && hexo g && hexo d 看看这两个文件有没有进去。

@palemoky
Copy link
Author

palemoky commented Dec 10, 2016

大脑短路,在博客目录下执行了hexo init,然后配置文件就初始化了,搞了半天才恢复,后来试了一下,这两个文件还是写不进去。

以后我的所有文件都要用git管理!!!

@D0n9X1n D0n9X1n added the bug label Dec 10, 2016
@D0n9X1n D0n9X1n self-assigned this Dec 10, 2016
@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 10, 2016

你的系统是 Linux 还是 Windows ? 我这边想重现下你的现象。

@palemoky
Copy link
Author

palemoky commented Dec 10, 2016

Mac的,系统版本:Sierra 10.12.1

@palemoky
Copy link
Author

palemoky commented Dec 10, 2016

我这边也尽可能测试一下这个情况,我先把版本控制处理好,然后可能要帮朋友在Ubuntu下搭建,我再试试

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 10, 2016

我这边没有遇到你描述的这个问题: 测试网址

我的系统参数:

Snail :: Workspace/js-code/hexo » hexo --version
hexo: 3.2.2
hexo-cli: 1.0.2
os: Darwin 16.1.0 darwin x64
http_parser: 2.7.0
node: 7.2.1
v8: 5.4.500.44
uv: 1.10.1
zlib: 1.2.8
ares: 1.10.1-DEV
modules: 51
openssl: 1.0.2j
icu: 58.1
unicode: 9.0
cldr: 30.0.2
tz: 2016g

image

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 10, 2016

你试试看,rm -rf .deploy_git 文件夹还有 rm -rf public 文件夹。然后再 hexo clean && hexo g

理论上再执行 hexo d 的时候,是会把 public 文件夹下的所有内容都拷贝到 .deploy_git 下面,这两个文件夹应该是一致的。如果是 public 文件夹和 .deploy_git 文件夹内容不同,你可以发个 issue 到 hexo 的官方库里面问一下。

@palemoky
Copy link
Author

palemoky commented Dec 11, 2016

经过多次的尝试,我终于发现的问题。

这种现象确实是存在的,主要原因是我使用了组合命令,比如:hexo clean && hexo d -g或者hexo clean然后执行hexo d -g或者hexo g -d,在这种情况下,就会导致那两个文件没有推送上去。

简而言之,就是hexo d要单独执行,其他命令可以组合执行,否则就会导致无法推送那两个文件。

顺便问一下作者,我看你的demo页面标签云显示在首页,那个主题默认是在分类里边的,我想问你是怎么移动过来的,毕竟我对这方面空白,谢谢。

另外,自己以后报告bug时,应该详细描述问题外,还应该有当时的运行环境,以便作者复现问题,提高过沟通效率。

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 11, 2016

我这边修改的是 hexo-theme-primer/layout/_widget/sidebar.ejs 这个文件。

修改后的内容:

<%- partial('sidebar-search') %>
<%- partial('sidebar-github-repo') %>

<% if (site.tags.length){ %>
    <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
    <div class="widget-wrap">
        <h3 class="widget-title"><%= __('tagcloud') %></h3>
        <div id="myCanvasContainer" class="widget tagcloud">
            <canvas width="250" height="250" id="resCanvas" style="width=100%">
                <%- tagcloud() %>
            </canvas>
        </div>
    </div>
<% } %>

@palemoky
Copy link
Author

palemoky commented Dec 11, 2016

标签云成功移动到首页了。

再补充一下tag文件的提交问题,就是之前已经提交成功了,使用hexo d -g等组合命令也会删除这两个文件(见下图),因此,用组合命令提交是无论如何都无法正常显示的。

@D0n9X1n
Copy link
Owner

D0n9X1n commented Dec 11, 2016

好的。我这边记下了。我有空去查下问题。

@dexhunter
Copy link

dexhunter commented Feb 3, 2017

我也是遇到這個問題,然後手動複製了兩個js文件,不知道這個問題作者現在有沒有新的方法?

@D0n9X1n
Copy link
Owner

D0n9X1n commented Feb 3, 2017

也是因為組合命令嗎?是 hexo d -g 這樣無法複製文件還是 hexo clean && hexo g && hexo d 這樣無法複製文件?
另外你的版本信息方便發一下嗎?

@D0n9X1n D0n9X1n closed this as completed Jul 12, 2017
D0n9X1n added a commit that referenced this issue Oct 29, 2017
change the trigger from `exit` to `after_generate`
D0n9X1n added a commit that referenced this issue Oct 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants