ربط بعنوان داخل منشور أو موضوع

:bookmark: This guide explains how to link directly to a heading within a Discourse post or topic, enabling users to navigate long posts efficiently.

:person_raising_hand: Required user level: All users

Adding headings within long posts can make the content more readable and allow users to link directly to specific sections. This can be particularly useful for navigating extensive discussions and documentation.

Summary

This guide covers:

  • Creating headings using Markdown
  • Linking directly to specific headings in a post

Creating headings using Markdown

To create a heading in Markdown, prefix a line of text with one or more # characters. The number of # characters corresponds to the heading level. Here are some examples:

## This is a level 2 heading
Here is a short paragraph afterwards.

### This is a level 3 heading
Here is another short paragraph.

When rendered, it looks like this:


This is a level 2 heading

Here is a short paragraph afterwards.

This is a level 3 heading

Here is another short paragraph.


Linking directly to a heading

To share a direct link to a heading within a post:

  1. Hover over the heading to reveal a link icon next to it: link icon.
  2. Click the link icon to update the URL in your browser’s address bar with the direct link to that heading.
  3. Copy the updated URL from the address bar to share it with others.

Best practices

  • Use descriptive headings to summarize content clearly.
  • Structure your post using hierarchical headings where appropriate.
  • Ensure that headings are consistent and logical for better readability.

FAQs

Can I link to any part of a post?
Yes, as long as it’s a heading properly formatted in Markdown.

Do links to headings work across different posts?
Yes! These links will direct to the header in the post when used in other topics or shared somewhere else.

Additional resources

Last edited by @JammyDodger 2024-07-09T11:12:13Z

Last checked by @hugh 2024-08-08T01:48:04Z

Check documentPerform check on document:
73 إعجابًا

أنا لا أرى أيقونات الروابط على هذا الموقع أو على موقعي الخاص. لا في FF ولا في Chrome.

هل هناك شيء تغير؟

تحتاج إلى تحريك مؤشر الفأرة فوق العنوان لتظهر:

عندما أحرك مؤشر الماوس، لا أرى شيئًا.

يبدو أن هناك شيئًا ما موجودًا، ولكن لا يتم عرض أي أيقونة.

سؤال للمتابعة…

أفترض أنه إذا قمت بتغيير نص العنوان، فسوف ينقطع الرابط.

تعديل للإضافة: ليس فقط الرابط يتغير إذا تغير العنوان، ولكن إذا قمت بإدراج عنوان آخر قبل العناوين الموجودة، فسوف يتغير اللاحقة الرقمية على العنوان. يبدو هذا هشًا لدرجة أنه عديم الفائدة.

الحل الآمن الوحيد هو وضع العناوين في وسوم a لغة HTML وإعطائها مُعرّف (id)، صحيح؟

تعديل مرة أخرى للإضافة: لقد حاولت كلاً من وضع نص العنوان في وسوم a ووضع وسوم فارغة قبل نص العنوان مباشرةً. لم يعمل أي من المعرفات. حاولت أيضًا استخدام وسوم span بدلاً من ذلك مع نفس الفشل.

نعم، يمكنني العثور عليه في الـ DOM كـ before:

أنا على نظام التشغيل Windows 11.
الطريقة الوحيدة التي يمكنني من خلالها جعل أيقونة الرابط تظهر هي عن طريق نسخ الرابط ثم فتح هذا الرابط (مع الـ # والـ id) في علامة تبويب جديدة والانتقال إليه. عندها تظهر أيقونة الرابط بشكل دائم (بدون تحويم) ولكن لا تزال أيقونات الروابط الأخرى لا تظهر عند التحويم.

هل يُسمح لي برفع هذا الموضوع؟ أتساءل عما إذا كنت أغفل شيئًا واضحًا بشأن الربط داخل المشاركة.