# 路由
路由存儲了網站中所用到的所有路徑。
## 獲取路徑
`get` 方法會傳回一個 [Stream](http://nodejs.org/api/stream.html),例如把該路徑的資料存儲到某個指定位置。
```
var'index.html'
var'somewhere'
data.pipe(dest);
```
## 設置路徑
您可以在 `set` 方法中使用字符串、[Buffer](http://nodejs.org/api/buffer.html) 或函數,如下:
```
// String
hexo.route.set('index.html''index'
// Buffer
hexo.route.set('index.html'new'index'
// Function (Promise)
hexo.route.set('index.html'function{ returnnewPromisefunctionresolve, reject{ resolve('index'
});});// Function (Callback)
hexo.route.set('index.html'functioncallback{ callback(null'index'
});
```
您還可以設置該路徑是否更新,這樣在生成文件時便能忽略未更動的文件,加快生成時間。
```
hexo.route.set('index.html'
data: 'index'
modified: false
});// hexo.route.isModified('index.html') => false
```
## 移除路徑
```
hexo.route.remove('index.html'
```
## 獲得路由表
```
hexo.route.list();
```
## 格式化路徑
`format` 方法可將字符串轉為合法的路徑。
```
hexo.route.format('archives/'
// archives/index.html
```
- 文檔
- 開始使用
- 概述
- 建站
- 配置
- 指令
- 遷移
- 基本操作
- 寫作
- Front-matter
- 標簽插件(Tag Plugins)
- 資源文件夾
- 數據文件
- 服務器
- 生成文件
- 部署
- 自定義
- 永久鏈接(Permalinks)
- 主題
- 模版
- 變量
- 輔助函數(Helpers)
- 國際化(i18n)
- 插件
- 其他
- 問題解答
- 貢獻
- API
- 核心
- 概述
- 事件
- 局部變量
- 路由
- Box
- 渲染
- 文章
- 腳手架(Scaffold)
- 主題
- 擴展
- 控制臺(Console)
- 部署器(Deployer)
- 過濾器(Filter)
- 生成器(Generator)
- 輔助函數(Helper)
- 遷移器(Migrator)
- 處理器(Processor)
- 渲染引擎(Renderer)
- 標簽插件(Tag)