Skip to content

Tips for forked repos

cdmgtri edited this page Feb 10, 2021 · 1 revision

Problem

Default root-relative links will not work for viewing pages on a forked repo.

<link rel="stylesheet" href="/assets/css/main.css">  <!-- breaks -->
<link rel="stylesheet" href="assets/css/main.css">   <!-- works -->

<a href="/iepd-starter-kit/">  <!-- breaks -->
<a href="iepd-starter-kit/">   <!-- works -->

Fixing root-relative links

Use a relative link if possible.

Remove the initial /.

Set baseurl in _config.yml

baseurl: "NIEM.github.io"

Use a Jekyll template to prepend the baseurl to links:

{{ "myurl" | relative_url }}

Examples:

<a class="navbar-brand" href="{{ '/' | relative_url }}'">

[Title]({{ "/model/concepts/" | relative_url }})

Do not commit baseurl value to NIEM repo

Add _config.yml to .gitignore.

Override baseurl when viewing the pages on local development server

bundle exec jekyll serve --baseurl ''
Clone this wiki locally