Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note on absolute links #2507

Merged
merged 24 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
80be602
Add note on absolute links
jingting1412 Apr 8, 2024
6e3617b
Fix typos
jingting1412 Apr 8, 2024
92000fe
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 9, 2024
37dae13
Add tip to more pages
jingting1412 Apr 9, 2024
337ec36
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 11, 2024
fc0e857
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 11, 2024
7f25bb9
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 11, 2024
c9f1a47
Add negative example
jingting1412 Apr 11, 2024
cf4251f
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 11, 2024
ac5bc63
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 12, 2024
0fd7aa1
Update docs/userGuide/troubleshooting.md
jingting1412 Apr 12, 2024
5a2bb07
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
1f207ee
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
cdd953c
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 12, 2024
ed502e8
Add more details
jingting1412 Apr 12, 2024
686e19b
Improve explanation
jingting1412 Apr 12, 2024
ced6b4d
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 12, 2024
edfd5b0
Improve look of tip
jingting1412 Apr 12, 2024
9dff565
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
263eacd
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
1df6f67
Update docs/userGuide/syntax/includes.md
jingting1412 Apr 14, 2024
2d9d4f4
Merge branch 'MarkBind:master' into popup-docs
jingting1412 Apr 15, 2024
262c987
Implement review changes
jingting1412 Apr 15, 2024
1693d54
Merge branch 'master' into popup-docs
Tim-Siu Apr 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/userGuide/syntax/includes.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ When setting the `id` of a fragment, be careful not to clash with heading anchor
</box>

<include src="panels.md#script_and_styles_warning"></include>
<div id="baseUrl-warning">
<box type="warning" header="Add `{{ '{{ baseUrl }}' }}` to make your URLs absolute links if they may be reused in different contexts">

Make an internal relative link an absolute link by adding `{{ '{{ baseUrl }}' }}` in front of the path. This allows the link to always point to the same target. Keep this in mind when putting content with links that is reused (eg: via `<include>`) as when your content is re-used a relative link may no longer point to where you want it to.
jingting1412 marked this conversation as resolved.
Show resolved Hide resolved

<div id="baseUrl-example">
<panel header="Example of using absolute links in `<include>`" type="info">

The file `folder1/file1.md` contains a link to `folder1/target.html`. The file `folder2/file2.md` contains a fragment from `folder1/file1.md` using `<include>`.
jingting1412 marked this conversation as resolved.
Show resolved Hide resolved

**In `folder2/file2.md`:**
```
<include src="folder1/file1.md" />
```

<box type="success" header="Positive example">

To ensure that the link will still point to `folder1/target.html`, use an **absolute link** in `folder1/file1.md` as such: `{{ '{{baseUrl}}' }}/folder1/target.html`.
</box>

<box type="wrong" header="Negative example">

If a relative link `target.html` is used, the link will point to `folder2/target.html` instead of `folder1/target.html`
jingting1412 marked this conversation as resolved.
Show resolved Hide resolved
</box>
</panel>
</div>

</box>
</div>

<include src="tip.md" boilerplate >
<span id="tip_body">
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/links.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ To ensure that links in the <code>_markbind/</code> folder work correctly across
{% endraw %}
</div>

<include src="includes.md#baseUrl-warning"/>

****Relative paths****

<div class="indented">
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ To safeguard against unintended consequences, consider directly incorporating th
</variable>
</include>

<include src="includes.md#baseUrl-warning"/>

**If `preload` attribute is provided, the panel body will load the HTML when the page renders instead of after being expanded.**

<include src="codeAndOutput.md" boilerplate >
Expand Down
2 changes: 2 additions & 0 deletions docs/userGuide/syntax/popovers.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
</variable>
</include>

<include src="includes.md#baseUrl-warning"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-12 at 8 34 22 PM When embedded, it seems like the warning is very large and disrupts the flow of the text. Actually, even when it's not included the placing feels a little awkward. What if all or some of the content was in an expandable panel, so that it's out of the way? Just the header might be good? I suppose you could also experiment with having the example be expandable instead.

Copy link
Contributor Author

@jingting1412 jingting1412 Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep sure, I've put the example into a panel and changed the explanation to make it more clear! I think since this issue is about links breaking when being included with <include>, the note at the includes section in the UG and troubleshooting section is also just about this specific problem.

If there's another cause to the link breaking issue other than include I think we can make a more generic one?


**Using trigger for Popover:**<br>

<include src="codeAndOutput.md" boilerplate >
Expand Down
11 changes: 10 additions & 1 deletion docs/userGuide/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,13 @@ You could signpost Markdown either by:
<box> **This will be rendered as plain text**</box>
</variable>
</include>
</panel>
</panel>

##### Content with local links not working when included with `<include>`

If you notice that relative links in a page pointing to another page no longer works after adding it into a page via `<include>`, it may be because the relative link no longer points to the correct address in the new page with `<include>`.

To solve this, change the relative URL into an **absolute** URL by adding `{{ '{{ baseUrl }}' }}`. This will ensure that the link will always point to the same address regardless of the page it is included in.

<include src="syntax/includes.md#baseUrl-example"/>

Loading