[GH-ISSUE #1484] Bug: CUSTOM_TEMPLATES not working anymore #2384

Closed
opened 2026-03-01 17:58:40 +03:00 by kerem · 5 comments
Owner

Originally created by @tztzz on GitHub (Aug 10, 2024).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/1484

Dear fellows,

according to your guide it should be easy to use custom templates by defining the CUSTOM_TEMPLATES variable within the configuration file. I did this accordingly on a Debian 12 bare-metal setup but it doesn't reflect any changes I made to the copied templates.

Executing archivebox version shows that everything is fine (checkmark):

 √  CUSTOM_TEMPLATES_DIR  3 files         valid     ./custom_templates   

The folder itself needs to be located at ~/archivebox/data, its content is:

custom_templates/:
admin  core  static

custom_templates/admin:
actions_as_select.html  app_index.html  base.html  login.html  private_index.html  private_index_grid.html  snapshots_grid.html

custom_templates/core:
add.html  base.html  index_row.html  minimal_index.html  navigation.html  progressbar.html  public_index.html  snapshot.html  static_index.html

custom_templates/static:
add.css  admin.css  archive.png  bootstrap.min.css  external.png  favicon.ico  jquery.dataTables.min.css  jquery.dataTables.min.js  jquery.min.js  robots.txt  sort_asc.png  sort_both.png  sort_desc.png  spinner.gif

I tried several changes to the path, moving files and folders, restarting the server. It seems that Django is ignoring this configuration setting.

Originally created by @tztzz on GitHub (Aug 10, 2024). Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/1484 Dear fellows, according to your guide it should be easy to use custom templates by defining the `CUSTOM_TEMPLATES` variable within the configuration file. I did this accordingly on a Debian 12 bare-metal setup but it doesn't reflect any changes I made to the copied templates. Executing `archivebox version` shows that everything is fine (checkmark): ``` √ CUSTOM_TEMPLATES_DIR 3 files valid ./custom_templates ``` The folder itself needs to be located at `~/archivebox/data`, its content is: ``` custom_templates/: admin core static custom_templates/admin: actions_as_select.html app_index.html base.html login.html private_index.html private_index_grid.html snapshots_grid.html custom_templates/core: add.html base.html index_row.html minimal_index.html navigation.html progressbar.html public_index.html snapshot.html static_index.html custom_templates/static: add.css admin.css archive.png bootstrap.min.css external.png favicon.ico jquery.dataTables.min.css jquery.dataTables.min.js jquery.min.js robots.txt sort_asc.png sort_both.png sort_desc.png spinner.gif ``` I tried several changes to the path, moving files and folders, restarting the server. It seems that Django is ignoring this configuration setting.
Author
Owner

@pirate commented on GitHub (Aug 11, 2024):

Ok I can investigate, please share the complete output of archivebox version first though.

<!-- gh-comment-id:2282665071 --> @pirate commented on GitHub (Aug 11, 2024): Ok I can investigate, please share the complete output of `archivebox version` first though.
Author
Owner

@keranbyge commented on GitHub (Nov 21, 2025):

Hi! I’ve gone through this issue and I believe the problem is related to Django not picking up the CUSTOM_TEMPLATES_DIR because the template directory isn’t being added correctly to TEMPLATES['DIRS'] during the settings load.

I’ll start by reproducing the bug locally, verifying how ArchiveBox resolves custom template paths, and checking where the configuration is being ignored. Once confirmed, I can submit a fix ensuring the custom template folder is properly registered in the Django settings.

Please let me know if there are any additional details or edge cases I should be aware of before I begin. I’d be happy to take this issue.

<!-- gh-comment-id:3563819652 --> @keranbyge commented on GitHub (Nov 21, 2025): Hi! I’ve gone through this issue and I believe the problem is related to Django not picking up the CUSTOM_TEMPLATES_DIR because the template directory isn’t being added correctly to TEMPLATES['DIRS'] during the settings load. I’ll start by reproducing the bug locally, verifying how ArchiveBox resolves custom template paths, and checking where the configuration is being ignored. Once confirmed, I can submit a fix ensuring the custom template folder is properly registered in the Django settings. Please let me know if there are any additional details or edge cases I should be aware of before I begin. I’d be happy to take this issue.
Author
Owner

@pirate commented on GitHub (Dec 29, 2025):

@claude can you fix this on dev

<!-- gh-comment-id:3697607205 --> @pirate commented on GitHub (Dec 29, 2025): @claude can you fix this on dev
Author
Owner

@claude[bot] commented on GitHub (Dec 29, 2025):

Claude finished @pirate's task in 4m 24s —— View jobclaude/issue-1484-20251229-2146Create PR ➔


Fix Implemented Successfully ✓

  • Read CLAUDE.md for repo-specific instructions
  • Locate CUSTOM_TEMPLATES_DIR configuration in codebase
  • Find Django TEMPLATES settings configuration
  • Identify why custom templates aren't being loaded
  • Implement fix to make CUSTOM_TEMPLATES_DIR configurable
  • Commit and push changes
  • Provide PR creation link

Root Cause

The CUSTOM_TEMPLATES_DIR configuration was removed from ServerConfig and hardcoded as a constant in archivebox/config/constants.py:87. This prevented users from customizing the templates directory location via ArchiveBox.conf or environment variables.

The commented-out line in common.py confirmed this:

# CUSTOM_TEMPLATES_DIR: Path = Field(default=None)  # this is now a constant

Solution Implemented

Restored CUSTOM_TEMPLATES_DIR as a configurable field in StorageConfig, following the same pattern as TMP_DIR and LIB_DIR.

Changes:

  1. archivebox/config/common.py: Added CUSTOM_TEMPLATES_DIR field to StorageConfig
  2. archivebox/core/settings.py: Updated to use STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR instead of constant
  3. archivebox/config/paths.py: Updated version output to use configurable value

Users can now configure the templates directory via:

  • ArchiveBox.conf: CUSTOM_TEMPLATES_DIR = ./custom_templates
  • Environment variable: export CUSTOM_TEMPLATES_DIR=/path/to/templates
  • Defaults to DATA_DIR/user_templates if not configured

Testing Instructions

To test this fix:

  1. Create a custom templates directory (e.g., ./custom_templates)
  2. Add your custom templates to it
  3. Configure it in ArchiveBox.conf:
    [STORAGE_CONFIG]
    CUSTOM_TEMPLATES_DIR = ./custom_templates
    
  4. Run archivebox version to verify it's detected
  5. Django will now load templates from your custom directory

| Branch: claude/issue-1484-20251229-2146

<!-- gh-comment-id:3697608223 --> @claude[bot] commented on GitHub (Dec 29, 2025): **Claude finished @pirate's task in 4m 24s** —— [View job](https://github.com/ArchiveBox/ArchiveBox/actions/runs/20583385435) • [`claude/issue-1484-20251229-2146`](https://github.com/ArchiveBox/ArchiveBox/tree/claude/issue-1484-20251229-2146) • [Create PR ➔](https://github.com/ArchiveBox/ArchiveBox/compare/dev...claude/issue-1484-20251229-2146?quick_pull=1&title=Fix%3A%20Make%20CUSTOM_TEMPLATES_DIR%20configurable%20again&body=%23%23%20Summary%0A%0AResolves%20%231484%20where%20CUSTOM_TEMPLATES_DIR%20configuration%20was%20being%20ignored.%0A%0AThe%20setting%20was%20previously%20removed%20from%20ServerConfig%20and%20hardcoded%20as%20a%20constant%2C%20preventing%20users%20from%20customizing%20the%20templates%20directory%20location.%0A%0A%23%23%20Changes%0A%0A-%20Added%20CUSTOM_TEMPLATES_DIR%20field%20to%20StorageConfig%20in%20common.py%0A-%20Updated%20settings.py%20to%20use%20STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR%0A-%20Updated%20paths.py%20to%20use%20configurable%20value%20in%20version%20output%0A%0A%23%23%20Usage%0A%0AUsers%20can%20now%20configure%20the%20custom%20templates%20directory%20via%3A%0A-%20ArchiveBox.conf%3A%20%60CUSTOM_TEMPLATES_DIR%20%3D%20.%2Fcustom_templates%60%0A-%20Environment%20variable%3A%20%60export%20CUSTOM_TEMPLATES_DIR%3D%2Fpath%2Fto%2Ftemplates%60%0A-%20Defaults%20to%20DATA_DIR%2Fuser_templates%20if%20not%20configured%0A%0AGenerated%20with%20%5BClaude%20Code%5D%28https%3A%2F%2Fclaude.ai%2Fcode%29) --- ### Fix Implemented Successfully ✓ - [x] Read CLAUDE.md for repo-specific instructions - [x] Locate CUSTOM_TEMPLATES_DIR configuration in codebase - [x] Find Django TEMPLATES settings configuration - [x] Identify why custom templates aren't being loaded - [x] Implement fix to make CUSTOM_TEMPLATES_DIR configurable - [x] Commit and push changes - [x] Provide PR creation link ### Root Cause The `CUSTOM_TEMPLATES_DIR` configuration was removed from `ServerConfig` and hardcoded as a constant in `archivebox/config/constants.py:87`. This prevented users from customizing the templates directory location via `ArchiveBox.conf` or environment variables. The commented-out line in `common.py` confirmed this: ```python # CUSTOM_TEMPLATES_DIR: Path = Field(default=None) # this is now a constant ``` ### Solution Implemented Restored `CUSTOM_TEMPLATES_DIR` as a configurable field in `StorageConfig`, following the same pattern as `TMP_DIR` and `LIB_DIR`. **Changes:** 1. **archivebox/config/common.py**: Added `CUSTOM_TEMPLATES_DIR` field to `StorageConfig` 2. **archivebox/core/settings.py**: Updated to use `STORAGE_CONFIG.CUSTOM_TEMPLATES_DIR` instead of constant 3. **archivebox/config/paths.py**: Updated version output to use configurable value **Users can now configure the templates directory via:** - `ArchiveBox.conf`: `CUSTOM_TEMPLATES_DIR = ./custom_templates` - Environment variable: `export CUSTOM_TEMPLATES_DIR=/path/to/templates` - Defaults to `DATA_DIR/user_templates` if not configured ### Testing Instructions To test this fix: 1. Create a custom templates directory (e.g., `./custom_templates`) 2. Add your custom templates to it 3. Configure it in `ArchiveBox.conf`: ```ini [STORAGE_CONFIG] CUSTOM_TEMPLATES_DIR = ./custom_templates ``` 4. Run `archivebox version` to verify it's detected 5. Django will now load templates from your custom directory --- | [Branch: claude/issue-1484-20251229-2146](https://github.com/ArchiveBox/ArchiveBox/tree/claude/issue-1484-20251229-2146)
Author
Owner

@pirate commented on GitHub (Dec 29, 2025):

merged the fix, let me know if you still experience any issues. (dev is under heavy active work, sorry if you hit other bugs when testing)

<!-- gh-comment-id:3697626818 --> @pirate commented on GitHub (Dec 29, 2025): merged the fix, let me know if you still experience any issues. (dev is under heavy active work, sorry if you hit other bugs when testing)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ArchiveBox#2384
No description provided.