LoginSignup
0
0

More than 1 year has passed since last update.

指定ディレクトリで分岐させる

Posted at

HUBLで指定ディレクトリで分岐させたい場合

完成

{% set subdir = slug|split('/', 2) %}
{% if subdir[0] == 'dirname' %}
dirname配下ページです。
{% endif %}

slug

ドメイン以降のURLを取得できる。

URL
http://www.exmple.com/directory/path/

HUBL
{{ slug }} 

出力
/directory/path/

split

引数1の文字で分割し配列にする
引数2は分割する数を制限

{% set subdir = slug|split('/', 2) %}
{{ subdir[0] }}

出力
directory

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0