Template not showing under template option in "add page" menu

So I created a mypage.yaml file and a mypage.html.twig file copy pasted directly from the grav documentation
And when I go to “Add page”, the template dropdown does not contain the template file I just created. I doubled checked all the files were in the correct folders, it just simply will not recognize the file I created as a selectable template for making a new page. If I directly create the file in the directory as user/pages/03.mypage/mypage.md, when I open the page in the admin panel it will be using the blog.html.twig template.
Am I missing something? I feel like I followed the documentation to the letter and it’s simply not working.

I think you also must have a blueprint for the template named same as template. Eg,:

# blueprints/mypage.yaml

title: My page
extends@:  default

I already have that, as I stated above,

I created a mypage.yaml file and a mypage.html.twig file … I doubled checked all the files were in the correct folders

Ah, missed that :sweat_smile: Probably slipped of my mind till read post to the end :smiley:
I remember I had exact same issue and the solution was very simple, just don’t recall what it was now. Could you post your yaml config and folder structure?

Do you mean ‘user/config/system.yaml’?

absolute_urls: false
timezone: ''
default_locale: null
param_sep: ':'
wrapped_site: false
reverse_proxy_setup: false
force_ssl: false
force_lowercase_urls: true
custom_base_url: ''
username_regex: '^[a-z0-9_-]{3,16}$'
pwd_regex: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}'
intl_enabled: true
http_x_forwarded:
  protocol: true
  host: false
  port: true
  ip: true
languages:
  supported: {  }
  default_lang: null
  include_default_lang: true
  include_default_lang_file_extension: true
  translations: true
  translations_fallback: true
  session_store_active: false
  http_accept_language: false
  override_locale: false
  content_fallback: {  }
  pages_fallback_only: false
home:
  alias: /home
  hide_in_urls: false
pages:
  type: regular
  theme: bootstrap4
  order:
    by: default
    dir: asc
  list:
    count: 20
  dateformat:
    default: null
    short: 'jS M Y'
    long: 'F jS \a\t g:ia'
  publish_dates: true
  process:
    markdown: true
    twig: false
  twig_first: false
  never_cache_twig: false
  events:
    page: true
    twig: true
  markdown:
    extra: false
    auto_line_breaks: false
    auto_url_links: false
    escape_markup: false
    special_chars:
      '>': gt
      '<': lt
    valid_link_attributes:
      - rel
      - target
      - id
      - class
      - classes
  types:
    - html
    - htm
    - xml
    - txt
    - json
    - rss
    - atom
  append_url_extension: ''
  expires: 604800
  cache_control: null
  last_modified: false
  etag: true
  vary_accept_encoding: false
  redirect_default_route: false
  redirect_default_code: 302
  redirect_trailing_slash: true
  ignore_files:
    - .DS_Store
  ignore_folders:
    - .git
    - .idea
  ignore_hidden: true
  hide_empty_folders: false
  url_taxonomy_filters: true
  frontmatter:
    process_twig: false
    ignore_fields:
      - form
      - forms
cache:
  enabled: true
  check:
    method: file
  driver: auto
  prefix: g
  purge_at: '0 4 * * *'
  clear_at: '0 3 * * *'
  clear_job_type: standard
  clear_images_by_default: true
  cli_compatibility: false
  lifetime: 604800
  gzip: false
  allow_webserver_gzip: false
  redis:
    socket: false
    password: null
    database: null
twig:
  cache: true
  debug: true
  auto_reload: true
  autoescape: true
  undefined_functions: true
  undefined_filters: true
  umask_fix: false
assets:
  css_pipeline: false
  css_pipeline_include_externals: true
  css_pipeline_before_excludes: true
  css_minify: true
  css_minify_windows: false
  css_rewrite: true
  js_pipeline: false
  js_pipeline_include_externals: true
  js_pipeline_before_excludes: true
  js_minify: true
  enable_asset_timestamp: false
  collections:
    jquery: 'system://assets/jquery/jquery-2.x.min.js'
errors:
  display: true
  log: true
log:
  handler: file
  syslog:
    facility: local6
debugger:
  enabled: false
  provider: clockwork
  censored: false
  shutdown:
    close_connection: true
  twig: true
images:
  default_image_quality: 85
  cache_all: false
  cache_perms: '0755'
  debug: false
  auto_fix_orientation: true
  seofriendly: false
  defaults:
    loading: auto
media:
  enable_media_timestamp: false
  unsupported_inline_types: {  }
  allowed_fallback_types: {  }
  auto_metadata_exif: false
  upload_limit: 2097152
session:
  enabled: true
  initialize: true
  timeout: 1800
  name: grav-site
  uniqueness: path
  secure: false
  httponly: true
  samesite: Lax
  split: true
  domain: null
  path: null
gpm:
  releases: stable
  proxy_url: null
  method: auto
  verify_peer: true
  official_gpm_only: true
accounts:
  type: regular
  storage: file
flex:
  cache:
    index:
      enabled: true
      lifetime: 60
    object:
      enabled: true
      lifetime: 600
    render:
      enabled: true
      lifetime: 600
strict_mode:
  yaml_compat: false
  twig_compat: false
  blueprint_compat: false

I hope you meant that because it’s really long and it’d be awkward if not :sweat_smile:
And here’s my folder structure:

I think that should be all the relevant folders/files.

Sorry I wasn’t clear. I meant mypage.yaml :slight_smile: I know I’ve spent almost an hour trying to figure out why my template wasn’t showing up… Your folder and file structure looks fine

Ahh sorry,

title: My Page Blueprint
'@extends':
    type: default
    context: blueprints://pages

form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        content:
          type: tab
          fields:
             header.newTextField:
              type: text
              label: 'New Text Field'

I took it right from the grav docs so I would hope there isn’t a big issue here, or else that kind of makes me wary of how many other errors that might be in there.

I think you can delete

      type: tabs
      active: 1

because default.yaml already has this

Same goes for

          type: tab

Also I’d change '@extends' to more up to date extends@ (without quotes)

But I think the main issue here is the indentation. Delete one (single) space before:

             header.newTextField:

Still isn’t working :confused: I thought for sure that might’ve been it with the extra space.
I also tried doing each of those steps one at a time frontward and backward, still no cigar.

Do you have Bootstrap4 theme active (I see same templates in screenshot, but just to be sure)? Just tried on fresh Grav install and even with corrupt indentation template shows up (but not the field in Content tab - for field to show up indentation needs to be fixed)

What do you have in your template? Although that shouldn’t matter :thinking:
Could there be by any chance somewhere a tab instead of a space in a blueprint?

My template is just

{% extends 'partials/base.html.twig' %}

{% block content %}
    {{ page.header.newTextField|e }}
    {{ page.content|raw }}
{% endblock %}

I thought it might’ve been my editor automatically converting spaces into tabs, but I opened it in notepad and saved it there where there was no doubt it was all only spaces, still no dice. Maybe I should just do a fresh reinstall of grav at this point? I’m at a loss.

Sorry, but I’m lost here too. I’m out of ideas :confused: Even tried your system.yaml, but I still can see the template

@Regi, I cannot reproduce the issue. The following steps creates a new template as shown by the docs: Creating custom page templates

  • Fresh install of Grav 1.7.6
  • In theme Quark created file /user/themes/quark/templates/mypage.html.twig and added content from docs:
    {% extends 'partials/base.html.twig' %}
    
    {% block content %}
        {{ page.header.newTextField|e }}
        {{ page.content|raw }}
    {% endblock %}
    
  • Created file /user/themes/quark/blueprints/mypage.yaml and added the contents from the docs:
    title: My Page Blueprint
    '@extends':
        type: default
        context: blueprints://pages
    
    form:
     ...etc.
    
  • Opened browser to ‘localhost/admin/pages’
    • Click ‘+ Add’
    • In ‘Add Page’ modal clicked dropdown ‘Page Template’
    • Template ‘Mypage’ is shown.
    • Click 'Continue`
    • Tab ‘Content’ contains new field 'New Text Field`.

Note:

  • New template might not always show up in Admin immediately. A clearing of the cache and a refresh of Admin might help.

I figured it out, in part due to your comment. I had my installation at localhost/grav/ instead of directly at the root (localhost) and I guess it did not like that. My template is showing up in the menu now, which is still strange to me that all the other templates still worked while being in the same path despite also not being installed on the root of my webserver. Kind of a silly problem but thanks for all the input and help.

@Regi, I highly doubt that moving from subdirectory to the root is the solution.

Using localhost/grav/site-dev works fine, although a clearing of the cache and a refresh of the page might be required.

What I find more likely in your case, is that moving from subdirectory to root, causes Admin to read the data afresh instead from the cache. That caused the template to be visible.

If instead you are now able to create new templates and every template is immediately available (without clearing cache + refresh), then you are right.

Oh I see now, I guess because I was clearing the browser/application cache instead of grav’s actual cache folders via the “clear cache” button it wasn’t actually refreshing it properly. Opening it on another browser and using the “clear cache” button on the admin panel both caused a new template to show up. Sorry for the confusion on my part.

1 Like