Theme Drupal 11 tanpa base theme (base theme: false) — benar-benar kosong,
siap dibangun dari nol. Termasuk generator & validator agar bisa dipakai ulang
untuk nama theme apa pun.
- Repo isi theme siap pakai:
blank_theme.*,css/,templates/ - Tooling:
tools/new-theme.sh(generator),tools/check-theme.php(validator),tools/theme-template/(sumber dengan token__THEME__)
cd /path/ke/proyek-drupal
git clone https://github.com/busanonly/drupal-blank-theme.git web/themes/custom/blank_theme
# atau salin tanpa git:
# cp -r drupal-blank-theme web/themes/custom/blank_themeNama folder harus sama dengan machine name (blank_theme), karena Drupal
mencocokkan nama folder dengan nama file <machine_name>.info.yml.
Aktifkan:
drush theme:enable blank_theme -y
drush config:set system.theme default blank_theme -y
drush cr
# UI: /admin/appearance → "Install and set as default"# dari root proyek Drupal (auto-deteksi web/themes/custom)
sh web/themes/custom/blank_theme/tools/new-theme.sh blog_theme "Blog Theme"
# atau dari mana saja, target eksplisit
sh drupal-blank-theme/tools/new-theme.sh blog_theme "Blog Theme" /path/proyek/web/themes/customHasil: web/themes/custom/blog_theme/ lengkap (nama file & isi otomatis
disubstitusi). Opsi tambahan: FORCE=1 untuk menimpa theme yang sudah ada.
Jalankan dari dalam proyek Drupal (butuh vendor/autoload.php + web/core):
php web/themes/custom/blank_theme/tools/check-theme.php blank_themeYang diperiksa:
| Pemeriksaan | Keterangan |
|---|---|
| YAML valid | *.info.yml, *.libraries.yml bisa di-parse |
Key wajib info.yml |
name, type, core_version_requirement, base theme |
| Region | semua key regions: benar-benar dirender di templates/page.html.twig |
| Sintaks Twig | struktur semua templates/*.html.twig di-parse (filter Drupal didaftarkan dummy) |
| PHP lint | php -l pada <theme>.theme |
| Dikenali Drupal | InfoParser + ExtensionDiscovery (theme terdeteksi, base theme kosong) |
Contoh keluaran: RINGKASAN: SEMUA VALIDASI LULUS.
drupal-blank-theme/
├── blank_theme.info.yml # metadata: name, type, core_version_requirement: ^11,
│ # base theme: false, libraries, 8 region
├── blank_theme.libraries.yml # library `base` → css/base.css (slot untuk JS)
├── blank_theme.theme # contoh hook PHP (preprocess/suggestions/form settings)
├── css/base.css # variabel CSS, reset ringan, layout dasar (+ grid sidebar)
├── templates/
│ ├── html.html.twig # <html>/<head>/<body> + placeholder CSS/JS Drupal
│ └── page.html.twig # render semua region + title/tabs/messages
└── tools/
├── new-theme.sh # generator theme (substitusi __THEME__ / __THEME_LABEL__)
├── check-theme.php # validator theme
└── theme-template/ # template sumber (dipakai generator)
Region yang tersedia: header, primary_menu, breadcrumb, highlighted,
help, content, sidebar_first, footer — deklarasikan di info.yml dan
render di templates/page.html.twig (validator memastikan keduanya sinkron).
base themewajib ada diinfo.yml; tanpa key itu Drupal melemparInfoParserException: Missing required key ("base theme"). Nilaifalseberarti theme tidak mewarisi apa pun (tidak memakaistable9/claro/olivero). Lihatcore/lib/Drupal/Core/Extension/ThemeExtensionList.php.- Meta
charset,viewport,Generator, favicon, dan librarysystem/base(berisi.visually-hidden,.focusable) sudah otomatis ditambahkan Drupal lewatsystem_page_attachments→ tidak perlu ditulis ulang dihtml.html.twig. - Nama folder theme harus sama dengan machine name (
<machine_name>.info.yml), kalau tidak Drupal menolak (extension name mismatch). - Setiap perubahan
*.info.yml,*.libraries.yml, atau*.themeperlu rebuild cache (drush cratau UI Performance). - Ingin memakai theme core sebagai basis? Ubah
base theme: olivero(mis.) diinfo.yml, atau pakai generator bawaan core:php core/scripts/drupal generate-theme namatheme --name="Nama Theme".
- Theming Drupal: https://www.drupal.org/docs/develop/theming-drupal
- Twig di Drupal: https://www.drupal.org/docs/develop/theming-drupal/twig-in-drupal
base themewajib: https://www.drupal.org/node/3066038