Auf meinem Computer greife ich auf meine Testwebseite unter der URL http://127.0.0.1:4000
zu. Auf dem Server wird es auf GitHub-Seiten sein, das heißt https://username.github.io/repo-name/
.Wie kann ich verschiedene Basis-URL der Jekyll-Webseite auf dem lokalen Host und Remote-Server einfach verwalten?
Im _config.yml
Ich sehe folgende Einstellungen vor:
# Uncomment if you are planning to run the blog in a subdirectory
# Note - if you enable this, and attempt to view your site locally you have to use the baseurl in your local path.
# Example, you must use http://localhost:4000/path/to/blog
#baseurl: /path/to/blog
baseurl:
# The URL of your actual domain. This will be used to make absolute links in the RSS feed.
url: http://yourdomain.com/
Also für GitHub Server ich es muss sein:
baseurl: /repo-name/
url: https://username.github.io/
Aber auf localhost, muss es sein:
baseurl:
url: http://127.0.0.1:4000
Diese Einstellungen sind notwendig, weil ohne sie ich 404 Fehler für Ressourcen bekommen werde verwenden relative Pfade:
<script src="js/ghapi.js"></script>
"NetworkError: 404 Not Found - http://127.0.0.1:4000/download/js/ghapi.js"
Der Weg http://127.0.0.1:4000/js/ghapi.js
sein sollte, aber da die Seite war /download
es wurde auf die relative URL der Skriptdatei hinzugefügt.
Ich muss mit diesem Problem umgehen, wie mache ich das?
Wäre eine andere config.yml für die lokale Entwicklung als Serve-Parameter eine Lösung für Sie definiert? Es gibt eine [ähnliche Frage] (http://stackoverflow.com/a/20587233/1456318) auf SO. – michaPau
Mögliches Duplikat von [site.url während lokaler jekyll-Entwicklung zu localhost ändern] (http://stackoverflow.com/questions/27386169/change-site-url-to-localhost-during-jekyll-local-development) –