Ghost博客備份
- Ghost博客本身支持一些數據的導出,瀏覽網址/ghost/debug/ 選擇導出【EXPORT】將會得到一個json文件。
- Ghost 0.5.6版本之后的导出网址为 /ghost/settings/labs/
,后台 setting > labs 选项卡。
- 備份 content/themes 及 content/images 文件夾
- 【可選】停止Ghost服務後備份content/data 文件夾
Ghost博客升級
有人說可以不用在更新前停止Ghost服務,直接更新完了重啟服務就行,小雪未驗證。
- 停止Ghost服務 (例如: 在Ghost文件夾根目錄下運行 forever stop index.js 命令)
- cd定位到Ghost博客服務文件夾,然後依次運行以下命令
- wget https://ghost.org/zip/ghost-latest.zip
- unzip -uo ghost-latest.zip
- npm install –production
- rm ghost-latest.zip
- sudo npm start –production (或者跟小雪一樣使用NODE_ENV=production forever start index.js 啟動Ghost博客服務)
手動建立Ghost博客 Sitemap【更新:Ghost 0.5.6版本以上默认开启Sitemap】
ghost博客系統版本數到了0.5.5了還沒有支持sitemap真是丫丫丫丫丫丫,令人抓狂。 其實已經有人給出了自動建立Ghost博客sitemap的方法,但是小雪想說以後官方肯定會支持的,萬一方法不同有衝突,到時再改來改去實在夠折騰,就還是選擇了手動建立的方法。雖然笨一些,還要自己定時建立新的sitemap放上去,但是這個笨辦法對Ghost系統本身修改很少,要再改回來也很簡單。嘛, every coin has two sides 的喇~~
- 建立一個sitemap (推薦Create your Google Sitemap Online,免費的最多支持500個鏈接)
- 將
sitemap.xml
上傳至content
文件夾下 - 修改 core/server/routes/frontend.js 文件
- 在文件前部的var中添加 path = require(‘path’),
- 在 return router; 前添加 router.get(/^/sitemap.xml/$/, function (req, res, next) { res.download(path.join(__dirname, ‘/../../../content/sitemap.xml’));});
- 修改完的
frontend.js
文件大致如下:var frontend = require('../controllers/frontend'), config = require('../config'), express = require('express'), utils = require('../utils'), path = require('path'), frontendRoutes; frontendRoutes = function () { var router = express.Router(), subdir = config.paths.subdir; // ### Admin routes router.get(/^/(logout|signout)/$/, function redirect(req, res) { /*jslint unparam:true*/ res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); res.redirect(301, subdir + '/ghost/signout/'); }); router.get(/^/signup/$/, function redirect(req, res) { /*jslint unparam:true*/ res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); res.redirect(301, subdir + '/ghost/signup/'); }); // redirect to /ghost and let that do the authentication to prevent redirects to /ghost//admin etc. router.get(/^/((ghost-admin|admin|wp-admin|dashboard|signin|login)/?)$/, function (req, res) { /*jslint unparam:true*/ res.redirect(subdir + '/ghost/'); }); // ### Frontend routes router.get('/rss/', frontend.rss); router.get('/rss/:page/', frontend.rss); router.get('/feed/', function redirect(req, res) { /*jshint unused:true*/ res.set({'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S}); res.redirect(301, subdir + '/rss/'); }); // Tags router.get('/tag/:slug/rss/', frontend.rss); router.get('/tag/:slug/rss/:page/', frontend.rss); router.get('/tag/:slug/page/:page/', frontend.tag); router.get('/tag/:slug/', frontend.tag); // Authors router.get('/author/:slug/rss/', frontend.rss); router.get('/author/:slug/rss/:page/', frontend.rss); router.get('/author/:slug/page/:page/', frontend.author); router.get('/author/:slug/', frontend.author); // Default router.get('/page/:page/', frontend.homepage); router.get('/', frontend.homepage); router.get('*', frontend.single); // Customization for sitemap file. router.get(/^/sitemap.xml/$/, function (req, res, next) { res.download(path.join(__dirname, '/../../../content/sitemap.xml')); }); // End sitemap customization. return router; }; module.exports = frontendRoutes;
Leave a Reply