Skip to content

Instantly share code, notes, and snippets.

@alexmwalker
Last active June 29, 2025 10:27
Show Gist options
  • Save alexmwalker/7ad4a69da75ea497d7db6076d217a306 to your computer and use it in GitHub Desktop.
Save alexmwalker/7ad4a69da75ea497d7db6076d217a306 to your computer and use it in GitHub Desktop.
The URL delivering the page title
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Page Title</title>
<!-- Add your CSS files or <style> blocks here -->
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
</style>
</head>
<body>
<header>
<h1>Welcome to Your Site</h1>
</header>
<p>The URL of this page is: <span id="current-url"></span></p>
<ul id="url-parts-list">
<!-- URL parts will be appended here -->
</ul>
<main>
<!-- Your main content goes here -->
</main>
<footer>
<p>&copy; 2025 Alex</p>
</footer>
<!-- Add your JS files or <script> blocks here -->
<script>
document.addEventListener('DOMContentLoaded', function() {
// Get the current URL
var currentUrl = window.location.href;
var urlParts = currentUrl.split('/');
// Display the current URL in the designated span
document.getElementById('current-url').textContent = currentUrl;
// Loop through urlParts and append each as an <li>
var list = document.getElementById('url-parts-list');
urlParts.forEach(function(part) {
var li = document.createElement('li');
li.textContent = part;
list.appendChild(li);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment