Of course! Let's break down {dede:field.arcurl /} in detail.

What is {dede:field.arcurl /}?
In short, {dede:field.arcurl /} is a DedeCMS (织梦CMS) template tag used to display the full URL of the current article or page.
It's one of the most frequently used and essential tags in DedeCMS template development.
Key Characteristics
-
Context-Dependent: Its value changes depending on where it's used.
- In an article template (
article_article.htm), it will output the URL of that specific article. - In a list template (
list_*.htm), when used within a{dede:list}loop, it will output the URL of each article in the list. - In a channel or category template, it will output the URL of that channel or category page.
- In an article template (
-
No Closing Tag: It's a self-closing tag, written as
{dede:field.arcurl /}. You don't put anything between the opening and closing parts.
(图片来源网络,侵删) -
Absolute URL: By default, it generates a full URL (e.g.,
https://www.yourdomain.com/a/2025/1234.html), not a relative one (e.g.,/a/2025/1234.html). This is very good for SEO and sharing links.
How to Use It (with Examples)
In an Article Template (article_article.htm)
This is the most common use case. You want to display the URL of the article the visitor is currently reading, often for sharing purposes.
Example: Let's say you want to add a "Share this article" link or display the URL for the user to copy.
<h1>{dede:field.title /}</h1>
<div class="article-content">
{dede:field.body /}
</div>
<div class="article-footer">
<p><strong>Article URL:</strong></p>
<input type="text" value="{dede:field.arcurl /}" size="80" readonly />
<p><a href="https://www.facebook.com/sharer/sharer.php?u={dede:field.arcurl /}" target="_blank">Share on Facebook</a></p>
<p><a href="https://twitter.com/intent/tweet?url={dede:field.arcurl /}" target="_blank">Share on Twitter</a></p>
</div>
In this example, {dede:field.arcurl /} will be replaced by the actual URL of the article being viewed.
In a List Template (list_*.htm)
When you are looping through a list of articles using the {dede:list} tag, you use {dede:field.arcurl /} inside the loop to create a link for each article.
Example: A standard list template where each article title links to its full page.
<h2>{dede:field.title /}</h2> <!-- This is the title of the category/channel -->
<ul class="article-list">
{dede:list pagesize='10'}
<li>
<!-- Use arcurl to create the link for each article -->
<a href="{dede:field.arcurl /}">{dede:field.title /}</a>
<span class="date">({dede:field.pubdate function="MyDate('Y-m-d', @me)"/})</span>
</li>
{/dede:list}
</ul>
<!-- Pagination -->
<div class="pagination">
{dede:pagelist listsize='4' iteminfo='index' listitem='info,index,next,end,pre,pageno' function='html2text(@me)'}
</div>
Here, for each item in the list, {dede:field.arcurl /} provides the unique URL for that specific article, allowing the <a> tag to link correctly.
Common Issues and Troubleshooting
"404 Page Not Found" or Incorrect URL
This is the most frequent problem. If {dede:field.arcurl /} is generating a URL that leads to a 404 error, it's almost always related to URL Rewriting (伪静态).
Solution:
- Check if Rewriting is Enabled: Go to your DedeCMS backend -> System (系统) -> Site Settings (系统基本参数) -> Core Settings (核心设置).
- Verify that "是否使用伪静态" (Use Pseudo-static) is set to "Yes".
- Check your
.htaccessfile: If you are on an Apache server, you must have a correctly configured.htaccessfile in your website's root directory. DedeCMS provides a sample file, but you must ensure it's uploaded and named correctly. - Check Nginx/Apache Config: If you are using Nginx or a custom Apache configuration, ensure the rewrite rules are correctly applied to your server.
The URL is Relative (e.g., /a/1/2.html)
While DedeCMS usually generates absolute URLs, if you see a relative one, it might be due to a misconfiguration or a specific template setting.
Solution:
- The default behavior is to be absolute. If you need to force an absolute URL, you can sometimes use a modifier, but the standard
{dede:field.arcurl /}should work. Check your site's global URL settings in the backend first.
The Tag is Not Working (Outputting {dede:field.arcurl /} as plain text)
This means the DedeCMS parser is not recognizing the tag.
Solution:
- Typos: Double-check for any typos in the tag name.
{dede:field.arcurl /}is correct. - Template Caching: DedeCMS caches compiled templates. Try clearing the cache. Go to System (系统) -> Performance Optimization (性能优化) -> Clear All Cache (清除所有缓存).
- File Permissions: Ensure your template files (e.g.,
article_article.htm) have the correct read permissions for the web server.
Summary
| Tag Name | {dede:field.arcurl /} |
|---|---|
| Purpose | To display the full URL of the current article, list item, or category page. |
| Common Use Case | Creating links in list templates ({dede:list} loop) or displaying the URL on an article page. |
| Example | <a href="{dede:field.arcurl /}">Read More</a> |
| Key Dependency | URL Rewriting (Pseudo-static). If this is not set up correctly, the URLs will be broken. |
| Troubleshooting | Check URL Rewriting settings, clear template cache, and verify for typos. |
