rel-tag-faq: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
No edit summary
(mod_rewrite examples; URL syntax clarification; typographical, hypertextual, and editorial niceties)
Line 1: Line 1:
= rel-tag frequently asked questions =  
= rel-tag frequently asked questions =  


This document serves to answer and discuss frequently asked questions specifically about the [[rel-tag]] microformat. You may want to read the [[rel-faq]] first as it answers many common questions about the HTML4 "rel" and "rev" attributes, and their linktype values.  If you have a new question to ask, Please consider first asking your question on the microformats-discuss (http://microformats.org/mailman/listinfo/microformats-discuss/) list.
This document serves to answer and discuss frequently asked questions specifically about the [[rel-tag]] microformat. You may want to read the [[rel-faq]] first as it answers many common questions about the HTML4 “rel” and “rev” attributes, and their linktype values.  If you have a new question to ask, first consider asking on the [http://microformats.org/mailman/listinfo/microformats-discuss/ microformats-discuss list].


== Q&A ==
== Q&A ==


# ''Where does a rel link belong? I am specifically thinking about the rel="tag" links and my weblog.  Does the tag only need to appear in my web feed (RSS / Atom)?  Does the tag need to appear on the page where my specific blog entry lies?  Does it need to appear everywhere I can possibly imagine?''
# ''Where does a tagging link belong? Does the tagging link only need to appear in my Web feed (RSS / Atom)?  Does the tagging link need to appear on the page where my specific blog entry lies?  Does the tagging link need to appear everywhere that I can possibly imagine?''
#* In short, all the places/formats you published tagged content. The web page is always the primary location that users read content, search engines index, and thus the place where you should absolutely be including your [[rel-tag]] links. To tag your blog posts, put the [[rel-tag]] links inside them, visibly. The web feeds are simply alternate ways of publishing your blog posts, thus should include the full content of your blog posts, including your [[rel-tag]] links in those contents.
#* In short, tagging links belong in all the places and formats in which you published tagged content. The Web page is the primary location where users read content and where search engines index. Thus the Web page is a place where you should absolutely include your [[rel-tag]] links. To tag your blog posts, put the [[rel-tag]] links inside them, visibly. The Web feeds are simply alternate ways of publishing your blog posts, and thus should include the full content of your blog posts, [[rel-tag]] links intact.
# ''The format specifies that the tag must 'come after the last / in the path'... but will something like http://example.com/index.php/TAG work?  or does it have to be a 'real' directory or mod_rewrite? -- [[User:Singpolyma|singpolyma]] 23:51, 24 Jan 2006 (PST)''
# ''The format specifies that the tag must “come after the last / in the path”. Will something like <code><nowiki>http://example.com/index.php/TAG</nowiki></code> work?  Or does it have to be a “real” directory or [http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html mod_rewrite]? -- [[User:Singpolyma|singpolyma]] 23:51, 24 Jan 2006 (PST)''
#* The key is the URL. Whether that URL is generated from a database or a directory does not matter. The URL matters.
#* The key is the URL. Whether that URL is generated from a database or a directory does not matter. The URL matters.
#** My question, however, was if that url form ( http://example.com/index.php/TAG ) would be valid or not, since there is the dot in index.php
#** My question, however, was about whether that URL form ( <code><nowiki>http://example.com/index.php/TAG</nowiki></code> ) would be valid, since there is the dot in “index.php”.
# ''I'm developing a web application which uses tagging, and so of course I want to use [[rel-tag]]. For this I need a nice clean URL, so I was planning to use mod-rewrite to map a clean URL onto my underlying scripts. How do I use Apache's mod_rewrite to map: <code>http://localhost/~phil/app/tag/car</code> to <code>http://localhost/~phil/app/script.php?tag=car</code> ?''
#*** Yes, the URL in the example is valid (or legal or conformant or whatever you want to call it to minimize confusion). The dot (period, full stop, U+002E) is free to appear in most places in a URL, even in the middle of a path-segment that is not the last path-segment. (The latest specification for URLs, “[http://gbiv.com/protocols/uri/rfc/rfc3986.html Uniform Resource Identifier (URI): Generic Syntax]”, is RFC 3986.)
#* This should work
# ''I’m developing a web application which uses tagging, and so of course I want to use [[rel-tag]]. For this application, I want nice, clean URLs. I was planning to use [http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html mod_rewrite] to map a clean URL onto my underlying scripts. How do I use Apache’s [http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html mod_rewrite] to map <code><nowiki>http://example.org/~user/app/tag/car</nowiki></code> to <code><nowiki>http://example.org/~user/app/script.php?tag=car</nowiki></code> ?''
<pre><nowiki>
#* One solution involves changing the script to inspect the path for the tag (via the variable “PATH_INFO”), rather than inspecting the query:
<Directory "/home/phil/public_html/app/>
<pre><nowiki><Directory "/home/user/public_html/app/>
    RewriteEngine On
    RewriteRule ^~user/tag/([^/]+)$ script.php/$1 [last]
</Directory></nowiki></pre>
#* For people who can edit the server’s main configuration file, the following untested configuration code may work. Corrections are welcome.
<pre><nowiki>RewriteEngine On
RewriteMap tag int:escape
RewriteRule ^/~user/app/tag/([^/]+)$ /~user/app/script.php?tag=${tag:$1} [last]</nowiki></pre>
#* The following configuration code, left over from a previous contribution to this document, does a poor job according to tests. The following code fails to enforce the [[rel-tag]] rules about the tag corresponding to the last non-empty path-segment. The following code fails to transcode the tag for safe use in the URL query. Consider that a request on <code><nowiki>http://example.org/~user/app/tag/</nowiki></code> would map internally to a request on <code><nowiki>http://example.org/~user/app/script.php?tag=</nowiki></code> . Consider that a request on <code><nowiki>http://example.org/~user/app/tag/not-a-tag/the-tag</nowiki></code> would map internally to a request on <code><nowiki>http://example.org/~user/app/script.php?tag=not-a-tag/the-tag</nowiki></code> . Consider that a request on <code><nowiki>http://example.org/~user/app/tag/the-tag/</nowiki></code> would map internally to a request on <code><nowiki>http://example.org/~user/app/script.php?tag=the-tag/</nowiki></code> . Consider that a request on <code><nowiki>http://example.org/~user/app/tag/attack&intent=destroy</nowiki></code> would map internally to a request on <code><nowiki>http://example.org/~user/app/script.php?tag=attack&intent=destroy</nowiki></code> .
<pre><nowiki><Directory "/home/user/public_html/app/>
     RewriteEngine On
     RewriteEngine On
     RewriteRule ^tag/(.*)$ script.php?tag=$1
     RewriteRule ^tag/(.*)$ script.php?tag=$1
</Directory>
</Directory></nowiki></pre>
</nowiki></pre>
<ol start="4">
<ol start="4">
<li>''...next question''
<li>''...next question''

Revision as of 13:52, 24 March 2006

rel-tag frequently asked questions

This document serves to answer and discuss frequently asked questions specifically about the rel-tag microformat. You may want to read the rel-faq first as it answers many common questions about the HTML4 “rel” and “rev” attributes, and their linktype values. If you have a new question to ask, first consider asking on the microformats-discuss list.

Q&A

  1. Where does a tagging link belong? Does the tagging link only need to appear in my Web feed (RSS / Atom)? Does the tagging link need to appear on the page where my specific blog entry lies? Does the tagging link need to appear everywhere that I can possibly imagine?
    • In short, tagging links belong in all the places and formats in which you published tagged content. The Web page is the primary location where users read content and where search engines index. Thus the Web page is a place where you should absolutely include your rel-tag links. To tag your blog posts, put the rel-tag links inside them, visibly. The Web feeds are simply alternate ways of publishing your blog posts, and thus should include the full content of your blog posts, rel-tag links intact.
  2. The format specifies that the tag must “come after the last / in the path”. Will something like http://example.com/index.php/TAG work? Or does it have to be a “real” directory or mod_rewrite? -- singpolyma 23:51, 24 Jan 2006 (PST)
    • The key is the URL. Whether that URL is generated from a database or a directory does not matter. The URL matters.
      • My question, however, was about whether that URL form ( http://example.com/index.php/TAG ) would be valid, since there is the dot in “index.php”.
        • Yes, the URL in the example is valid (or legal or conformant or whatever you want to call it to minimize confusion). The dot (period, full stop, U+002E) is free to appear in most places in a URL, even in the middle of a path-segment that is not the last path-segment. (The latest specification for URLs, “Uniform Resource Identifier (URI): Generic Syntax”, is RFC 3986.)
  3. I’m developing a web application which uses tagging, and so of course I want to use rel-tag. For this application, I want nice, clean URLs. I was planning to use mod_rewrite to map a clean URL onto my underlying scripts. How do I use Apache’s mod_rewrite to map http://example.org/~user/app/tag/car to http://example.org/~user/app/script.php?tag=car ?
    • One solution involves changing the script to inspect the path for the tag (via the variable “PATH_INFO”), rather than inspecting the query:
<Directory "/home/user/public_html/app/>
    RewriteEngine On
    RewriteRule ^~user/tag/([^/]+)$ script.php/$1 [last]
</Directory>
    • For people who can edit the server’s main configuration file, the following untested configuration code may work. Corrections are welcome.
RewriteEngine On
RewriteMap tag int:escape
RewriteRule ^/~user/app/tag/([^/]+)$ /~user/app/script.php?tag=${tag:$1} [last]
    • The following configuration code, left over from a previous contribution to this document, does a poor job according to tests. The following code fails to enforce the rel-tag rules about the tag corresponding to the last non-empty path-segment. The following code fails to transcode the tag for safe use in the URL query. Consider that a request on http://example.org/~user/app/tag/ would map internally to a request on http://example.org/~user/app/script.php?tag= . Consider that a request on http://example.org/~user/app/tag/not-a-tag/the-tag would map internally to a request on http://example.org/~user/app/script.php?tag=not-a-tag/the-tag . Consider that a request on http://example.org/~user/app/tag/the-tag/ would map internally to a request on http://example.org/~user/app/script.php?tag=the-tag/ . Consider that a request on http://example.org/~user/app/tag/attack&intent=destroy would map internally to a request on http://example.org/~user/app/script.php?tag=attack&intent=destroy .
<Directory "/home/user/public_html/app/>
    RewriteEngine On
    RewriteRule ^tag/(.*)$ script.php?tag=$1
</Directory>
  1. ...next question
    • ..next answer