Skip to content

Commit

Permalink
Add URL debug message shown when baseurl is not configured correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
luost26 committed Jul 17, 2024
1 parent afcea84 commit 7913923
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
baseurl: "/" # the subpath of your site, e.g. /blog

# Build settings
markdown: kramdown
Expand Down
23 changes: 23 additions & 0 deletions _includes/widgets/url_debug_message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div id="url-debug-message" class="row mt-3 d-none">
<div class="col">
<div class="alert alert-warning my-0" role="alert">
<h5><i class="fas fa-exclamation-triangle"></i> Action required</h5>
<strong>Problem:</strong>
The current root path of this site is <code class="root-path-text"></code>,
which does not match the <code>baseurl</code> (<code>{{ site.baseurl }}</code>) configured in <code>_config.yml</code>.
<br>

<strong>Solution:</strong>
Please set the <code>baseurl</code> in <code>_config.yml</code> to "<code class="root-path-text"></code>".
</div>
</div>
</div>

<script>
if(location.pathname != "{{ site.baseurl }}"){
document.getElementById("url-debug-message").classList.remove('d-none');
}
document.querySelectorAll(".root-path-text").forEach(function(element){
element.textContent = location.pathname;
});
</script>
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
---
{% include widgets/profile_card.html %}

{% include widgets/url_debug_message.html %}

{% if site.data.display.homepage.show_experience %}
{% include widgets/experience_card.html %}
{% endif %}
Expand Down

0 comments on commit 7913923

Please sign in to comment.